Moving items to a new line


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Moving items to a new line
# 1  
Old 06-19-2011
Hammer & Screwdriver Moving items to a new line

Hi,

Let's I have the following strings (md5):

Code:
07177edf8261d28c6a003e583fcbe38c
0717c0037b3a20fc0f0998e673f228d5
0717d611a5d24374628b98e17fd00977,0717d611a5d24374628b98e17fd00977
07189a18afdae558bb5aadfe602e4a91
0719e97d481c239667f38a3e166bed74
071af3225fe50a1fdbb42c43aac313cc
071af3225fe50a1fdbb42c43aac313cc,071d5e253d25beab5fbf52306276e2db
0722012fee3e4a3220be750af9e03530
07234cc372614c2c24dc39a74d768876
072894ab3ada5f2ba13ffde6b642d222,072894ab3ada5f2ba13ffde6b642d222
072e2a308498065cbae22a752f92ecd0
072ef15fd47cf13ad537bec5c75eae62
072fc415848c2f31aad6702ca87fa852
07317233fae64c20d63f916442e43dad,07317233fae64c20d63f916442e43dad
0734c1b80b849285b1eaf2518469b740
073628c14abe56e025e973b8e1aef76e
07378b575b318638a4830711774ed820
07378b575b318638a4830711774ed820,07379d25fee06519ac3820fbb745ce27
0738030a25a32ec7808abd225a8a4e08
073ae0ecb922c7948c8ab8c3966a6554

I want to move them item with comma to a new line, say the next line. How can I do this. Currently I'm manually using
Code:
awk -F, {'print $1.....$n'}

but that is very tedious since I also have column up to 8,9... and almost 16.


Thanks.
# 2  
Old 06-19-2011
Post desired output for that sample please.
This User Gave Thanks to bartus11 For This Post:
# 3  
Old 06-19-2011
Code:
perl -0777 -pe 's/,/\n/g'

Or just

Code:
...  | tr ',' '\n'


Last edited by yazu; 06-19-2011 at 07:18 AM.. Reason: Another suggestion
# 4  
Old 06-19-2011
sed 's/,/\n/g' file.txt
# 5  
Old 06-19-2011
Quote:
Originally Posted by bartus11
Post desired output for that sample please.
single columned Smilie

Code:
0111844aed823108b007977cec035f37
0111844aed823108b007977cec035f37
0111a3de00c679ed6c0fbb8c6159cf83
01158d3c0c9da3e01e556a4b057e0940
0115ae0d3c679e3d259e55f531989543
01166d4f832ae67f480e95312e4e06e0
01166d4f832ae67f480e95312e4e06e0
01196852e42dd8f748a7da8eb8fa9b6e
011bbba2e3be13ea2aa84a1242e0d47b
012030d215e5207dd15ff3045d299210
012030d215e5207dd15ff3045d299210
01211232204f7a25b697c1159ce19a86
0121535cb52a1a90d0bbdda4efd65a86
0121535cb52a1a90d0bbdda4efd65a86
0122b82a91fda0699269aa346d93e9be

---------- Post updated at 07:21 PM ---------- Previous update was at 07:04 PM ----------

Quote:
Originally Posted by vipinable
sed 's/,/\n/g' file.txt
thanks, exactly i want Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Moving line above possible? after pattern match?

Team, would like to know if it is possibe to move line above.after TEST pattern match #cat file1 data1 data2 ok Test data1 ok Test data2 Test Output: Test (8 Replies)
Discussion started by: kenshinhimura
8 Replies

2. UNIX for Dummies Questions & Answers

Moving lines of file to command line

I have a file in which each line is the name of another file. Is there a way to serve them to the command line? For example, if the file contains file1.txt file2.txt file3.txt ... file9.txt is there a way to insert them in the command as a batch? If I ran a command like grep... (4 Replies)
Discussion started by: wbport
4 Replies

3. Shell Programming and Scripting

Moving line up if line starts with + sign.

Hello everyone, I'm struggling with this command: awk '!/^\+/{ORS=FS}/^\+/{ORS=RS}1' file1 > file2 What I want to do is to move any line that starts with the + sign 1 up, so its the continuation of the previous. The above command is messing the whole output, can you please let me know... (8 Replies)
Discussion started by: demmel
8 Replies

4. Shell Programming and Scripting

Moving a line to the end of the file

I have a file with different directories in it. I would need to move one line within the file to the end of the list. Also not there could be blank line in the middle of it. Example /vol/fs1 /vol/fs2 /vol/fs3 /vol/fs4 /vol/fs5 /vol/fs6 /vol/fs7 So I would need /vol/fs2... (3 Replies)
Discussion started by: bombcan
3 Replies

5. Shell Programming and Scripting

Help with shell script: moving end of line character

Hello. I have a file (old.txt) that I need to copy into another file (new.txt). Each line on old.txt ends with CR/LF but the position of CR/LF varies from one record to another. I need to copy each line of record to new.txt and move CR/LF in pos 165. Can I use awk to achieve this? How?... (8 Replies)
Discussion started by: udelalv
8 Replies

6. Shell Programming and Scripting

Sort items on a single line

I am creating some documentation that includes a list of packages that are to be installed for a Debian Server. This is a single line and I would like to sort the list of packages alphabetically. Using a small example of the packages, the best I could come up with was as follows: I create... (1 Reply)
Discussion started by: jelloir
1 Replies

7. Shell Programming and Scripting

awk between items including items

OS=HP-UX ksh The following works, except I want to include the <start> and <end> in the output. awk -F '<start>' 'BEGIN{RS="<end>"; OFS="\n"; ORS=""} {print $2} somefile.log' The following work in bash but not in ksh sed -n '/^<start>/,/^<end>/{/LABEL$/!p}' somefile.log (4 Replies)
Discussion started by: Ikon
4 Replies

8. Shell Programming and Scripting

deleting particular lines and moving a line up using perl/sed

Hi, I need convert a dump file in the following format : (please note that line numbers are provided for easy look) Original file: 1 2007-10-2482.90 No trade 0 0.00 100000.00 2 100000.00 3 0.00 4 HOLD 5 2007-10-2589.75 Bought 1114 1114 100000.00 0.00 ... (5 Replies)
Discussion started by: sabyasm
5 Replies

9. Shell Programming and Scripting

sh: Inserting tabs and moving text to 1 line

I trying to extract certain text from a csv file and then placing it into another csv file, but having problems getting the data to placed in one line with tab separated fields. Basically would like to have text sent to interfaces.csv in one line seperated by tabs. As it currently places files... (6 Replies)
Discussion started by: 00000008
6 Replies

10. Shell Programming and Scripting

moving to a specified line number

Hi Is there any command or a trick that can take me to a specifed line number in unix . Suppose i have a file with 2000 lines and i would like to go to line number 1899 and then print out the contents of the line. regards Hrishy (2 Replies)
Discussion started by: xiamin
2 Replies
Login or Register to Ask a Question

Featured Tech Videos