Results 1 to 5 of 5
How can I separate ls value by comma ?
I want to several is value like
ls -t -g
from
-rwxrwxrwxrwx 1 ali 44343 Fep 18 2002 sea.csv
to be ...
- 08-14-2007 #1Just Joined!
- Join Date
- Jul 2007
- Posts
- 31
How can I seperat ls value by comma ?
How can I separate ls value by comma ?
I want to several is value like
ls -t -g
from
-rwxrwxrwxrwx 1 ali 44343 Fep 18 2002 sea.csv
to be like this
-rwxrwxrwxrwx , 1 ali , 44343 , Fep ,18 , 2002 , sea.csv
Is there any way to do this in Unix c shell?
- 08-14-2007 #2Just Joined!
- Join Date
- Jul 2007
- Posts
- 41
I think sed should do it,
if you run:
Or:Code:ls -t -g | sed 's/\s\+/,/g'
This should replace whitespace with commas in the output.Code:ls -t -g | sed 's/ /,/g'
- 08-14-2007 #3Linux User
- Join Date
- Aug 2006
- Posts
- 458
Code:ls -t -g | awk 'BEGIN{OFS=","}$1=$1'
- 08-14-2007 #4Just Joined!
- Join Date
- Jul 2007
- Posts
- 31
Thank you but I need more ??!!!!
is there any way to combine two or three column
like all date in one column
-rwxrwxrwxrwx , 1 ali , 44343 , Fep ,18 , 2002 , sea.csv
I wont to be
-rwxrwxrwxrwx , 1 ali , 44343 , Fep 18 2002 , sea.csv
- 08-14-2007 #5Just Joined!
- Join Date
- Jul 2007
- Posts
- 41
There may be a neater way, but something like this should do it:
You may need to move around the commas and spaces in the print command depending on the exact output on your system.Code:ls -t -g | awk 'BEGIN{OFS=","} {print $1,$2,$3,$4,$5" "$6" "$7,$8;}'


Reply With Quote