![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| AIX AIX is IBM's industry-leading UNIX operating system that meets the demands of applications that businesses rely upon in today's marketplace. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Can df output be forced to a single line for each file system? | shew01 | Shell Programming and Scripting | 6 | 06-05-2008 08:25 AM |
| Multi-line output to single line | LinuxRacr | Shell Programming and Scripting | 7 | 02-26-2008 07:05 AM |
| run command Unix on a single line | Riddick61 | UNIX for Dummies Questions & Answers | 8 | 02-04-2008 11:19 AM |
| single line command | roshanjain2 | Shell Programming and Scripting | 4 | 02-07-2007 02:33 AM |
| Need output in different lines not in one single line | csaha | Shell Programming and Scripting | 1 | 02-08-2006 05:28 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
ls command output in single line
Hi,
Can anyone suggest me how can I display the output of ls command in single line with some delimiter say pipe (|)? I know it can be done by writing a script by using the loops but I wanted to know are there any other single line commands? Thanks for your help Sheshadri |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
If you have GNU ls, try:
Code:
ls -m Code:
ls -1 | awk '{ ORS="|"; print; }'
|
|
#3
|
||||
|
||||
|
The -1 option serves no purpose here.
Code:
printf "%s|" * |
|
#4
|
||||
|
||||
|
Wow reborg
Very cool solution! |
|
#5
|
|||
|
|||
|
Thank you guys.
|
|
#6
|
|||
|
|||
|
This is great
ls file* | awk '{ ORS="|"; print; }' But what if you want to put something in between? For example: file1|<filler1>|file2|<filler2>|file3|<filler3>|file4.... Thanks. |
|
#7
|
|||
|
|||
|
reborg wrote about eras usage of "ls -1":
This is a common misunderstanding about "ls". Because "ls" output has several columns when displayed on a screen one would assume that the same is the case when the output goes into a pipe. In fact "ls" determines if its output goes to a terminal or not and formats its output in columns or not. This can easily be demonstrated by issuing "ls > /some/file ; cat /some/file", which will show the same output as "ls -1" (to the screen), whereas "ls" (to the screen) will look different. (source: the AIX manpage of ls tells about this rather counter-intuitive behavior of ls) bakunin |
|||
| Google The UNIX and Linux Forums |