Customised Output

 
Thread Tools Search this Thread
Operating Systems Linux Red Hat Customised Output
# 1  
Old 11-26-2009
Customised Output

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.
# 2  
Old 11-26-2009
try:
Code:
ls -a|sort | xargs

# 3  
Old 11-26-2009
Or.

Code:
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)

Code:
ls -a | sort | awk -v ORS="\t" '1'

# 4  
Old 11-26-2009
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..... Smilie
# 5  
Old 11-26-2009
Ok...If you want it tab seperated, use the one below.

Code:
ls -a|sort | tr "\n" "\t"

# 6  
Old 11-26-2009
What does '1' specify in this command?

ls -a | sort | awk -v ORS="\t" '1'
# 7  
Old 11-26-2009
Quote:
Originally Posted by ashok.g
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.

The GNU Awk User's Guide: Patterns and Actions
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Red Hat

Command understanding the output file destination in case of standard output!!!!!

I ran the following command. cat abc.c > abc.c I got message the following message from command cat: cat: abc.c : input file is same as the output file How the command came to know of the destination file name as the command is sending output to standard file. (3 Replies)
Discussion started by: ravisingh
3 Replies

2. Shell Programming and Scripting

Displaying log file pattern output in tabular form output

Hi All, I have result log file which looks like this (below): from the content need to consolidate the result and put it in tabular form 1). Intercomponents Checking Passed: All Server are passed. ====================================================================== 2). OS version Checking... (9 Replies)
Discussion started by: Optimus81
9 Replies

3. Shell Programming and Scripting

script to mail monitoring output if required or redirect output to log file

Below script perfectly works, giving below mail output. BUT, I want to make the script mail only if there are any D-Defined/T-Transition/B-Broken State WPARs and also to copy the output generated during monitoring to a temporary log file, which gets cleaned up every week. Need suggestions. ... (4 Replies)
Discussion started by: aix_admin_007
4 Replies

4. Shell Programming and Scripting

Awk script to run a sql and print the output to an output file

Hi All, I have around 900 Select Sql's which I would like to run in an awk script and print the output of those sql's in an txt file. Can you anyone pls let me know how do I do it and execute the awk script? Thanks. (4 Replies)
Discussion started by: adept
4 Replies

5. Shell Programming and Scripting

customised error message..

Hi, Below is the script that takes some value from the properties file and then move the file from files folder to output folder based upon the modification time of files(configurable N days value),now at the end I want to show a customised message that if no files are moved then it shows the... (1 Reply)
Discussion started by: rahul125
1 Replies

6. Shell Programming and Scripting

awk: round output or delimit output of arithmatic string

I have a file with the following content. > cat /tmp/internetusage.txt 6709.296322 30000 2/7/2010 0.00I am using the following awk command to calculate a percentage from field 1 and 2 from the file. awk '{ print $1/$2*100 }' /tmp/internetusage.txt This outputs the value "22.3643" as a... (1 Reply)
Discussion started by: jelloir
1 Replies

7. Red Hat

running customised firewall -RHEL 4

I have created a custom firewall script in RHEL 4 .Let me explain the steps which i followed . etho -Internal lan eth1 -External lan During the installtion of RHEL 4 ,i enabled Firewall and after booting to x windows i selected enable firewall and defined the defined and customised ports... (0 Replies)
Discussion started by: sud.tech
0 Replies

8. Shell Programming and Scripting

how to make a line BLINKING in output and also how to increase font size in output

how to make a line BLINKING in output and also how to increase font size in output suppose in run a.sh script inside echo "hello world " i want that this should blink in the output and also the font size of hello world should be big .. could you please help me out in this (3 Replies)
Discussion started by: mail2sant
3 Replies

9. UNIX for Dummies Questions & Answers

customised filename

Hi, I am taking an output and redirecting it to a file name and this is a hourly or daily process , in this case, i want my file output as some logoutput_date_time.txt how can i form the file name like this for eg i am running this command now, so tail -f... (1 Reply)
Discussion started by: vasikaran
1 Replies

10. UNIX for Dummies Questions & Answers

customised functions...

I am going to build some commands/functions for common tasks that I have to perform (things like searching a filesystem for a certain string in a file). I intend to write these as unix scripts. Then adding the location of these to my path. How can I ensure that the variables specified when... (7 Replies)
Discussion started by: peter.herlihy
7 Replies
Login or Register to Ask a Question