When I write
ls | head -1
the output is
file.txt
When I write
ls | head -1 > output.txt or
echo `ls | head -1` > output.txt
the file output.txt contains
^[[H^[[2Jfile.txt
This makes me trouble because I need to use the output of head -1 as an argument of another command.
How can I achieve this?
Possibly your
lsis aliased to something likels --color=always. Try/bin/ls | head -1 > output.txt