Results 1 to 7 of 7
Hello friends,
I hav the file data1 which contains the following data
2002,12,25,12345
i tried the following command for a single column
cut -f2 -d',' data1 | paste - data1
...
- 10-22-2007 #1Just Joined!
- Join Date
- Oct 2007
- Posts
- 6
help with cut paste
Hello friends,
I hav the file data1 which contains the following data
2002,12,25,12345
i tried the following command for a single column
cut -f2 -d',' data1 | paste - data1
But the result wat am getting is
12,2002,12,25,12345
I need the above file to be rearranged in the order shown below
25,12,2002,12345
Since i am new in scripting, I request someone to help me
Thank you
- 10-22-2007 #2Code:
(IFS=,;set -- $(<data1);printf "%s,%s,%s,%s\n" "$3" "$2" "$1" "$4")
- 10-22-2007 #3Just Joined!
- Join Date
- Oct 2007
- Posts
- 37
If you want a simple bash one too, you could do:
Code:cat file | awk -F, '{print $3, $2, $1, $4}'
- 10-22-2007 #4Linux User
- Join Date
- Aug 2006
- Posts
- 458
- 10-22-2007 #5Linux Enthusiast
- Join Date
- Aug 2006
- Posts
- 631
The OP expects a comma as field separator:
RegardsCode:awk -F, '{print $3 "," $2 "," $1 "," $4}' file
- 10-23-2007 #6Linux User
- Join Date
- Aug 2006
- Posts
- 458
then try this:
Code:awk 'BEGIN{OFS=FS=","}{print $3,$2,$1,$4}' "file"
- 10-23-2007 #7Just Joined!
- Join Date
- Oct 2007
- Posts
- 6


Reply With Quote
