I want some customised output of following command:
$ls -a|sort
gives output as filenames line by line. But I want the output as filenames aeperated by tab? How can I get this?
Thanks in advance.
I want some customised output of following command:
$ls -a|sort
gives output as filenames line by line. But I want the output as filenames aeperated by tab? How can I get this?
Thanks in advance.
try:
ls -a|sort | xargs
Or.
ls -d $(ls -a | sort)
(although I think the basic ls output gives the files sorted anyway, so ls -a is the same as ls -a | sort)
Or all separated with tab (no newlines)
ls -a | sort | awk -v ORS="\t" '1'
Thanks for your reply. But I want to display the filenames seperated by tab. Actually, I am new to LInux. I dont know what is xargs?
Its better if you tell me for what we use xargs also.
Thanking you,
---------- Post updated at 04:50 PM ---------- Previous update was at 04:46 PM ----------
Thanks Dude its all working fine with the code.....
Ok...If you want it tab seperated, use the one below.
ls -a|sort | tr "\n" "\t"
What does '1' specify in this command?
ls -a | sort | awk -v ORS="\t" '1'
It is treated as a non-zero/not-null/TRUE expression pattern.
It's shorthand for
{ print }
(the default action when a condition is true. 1 is always true)