Home > Net >  Append in file a linux command
Append in file a linux command

Time:07-05

When doing

echo "some stuff" >> file.txt

I can append to my file some stuff But when trying to do

echo ls >> file.txt

I append ls instead of listing all my items in the current path. How can I fix this? Sorry I'm new to linux

CodePudding user response:

just redirect the ls output

ls >> file.txt

CodePudding user response:

echo ls >> file.txt

This is interpreted as echo the term ls to file.txt. This isn't what you want.

>> redirects the output of a command, which can be ls.

So you could do:

ls >> file.txt
  • Related