Single to multiple line file

Login or Register for Dates, Times and to Reply

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Single to multiple line file
# 1  
Network Single to multiple line file

I am working with single line file with 589744523 characters having 542 "^M" (line feed) character.
I want to make 542 different lines file from the single line file thr. shell program only (it can be done thr vi command)


sorry for duplicate post previously, actually i don,t know how to make further queries.

Last edited by anil_kut; 04-08-2010 at 01:58 PM.. Reason: not known
# 2  
echo 'a^Mb^M' | tr '\r' '\n'

'^M' is a single character.
# 3  
what is a and b
# 4  
Originally Posted by anil_kut
what is a and b
letters of the alphabet. why?
this is just a hint at a solution.
# 5  
ctrl/M is carriage-return not line-feed.
Was this file created as a text file on a M$ platform?
Does it just need converting to unix text file format with "dos2ux" or "dos2unix" depending on what unix you have?
# 6  


both tr and

not working

my i/p is like this
bikwenbl^Mbikwenbl^Mbikwenbl^M (single line)

o/p file should be like this
bikwenbl^M (3 lines)

---------- Post updated at 11:37 PM ---------- Previous update was at 10:59 PM ----------

thanks DAPTAL
you have already given the sol. very simple

awk -F '|' '{for(i=2;i<=NF;i++){ print $1.$i}}' filename

works very well even take ^M as delimiter

thanks all
# 7  
I have posted the fully correct "tr" command on your other thread.

Can't see the relevance of the "awk" example posted in this context.

What "awk" script did you actually use which worked?

The "dos2unix" command syntax posted in response to yet another of your threads is incorrect.
Now you know the command name, you can look it up in the unix manual pages yourself.

Last edited by methyl; 04-08-2010 at 09:17 PM.. Reason: rant
Login or Register for Dates, Times and to Reply

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #787
Difficulty: Medium
In early 2019, Bill Gates responded to the public backlash against billionaires by demanding a lower estate tax.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Splitting Single line into multiple line

Hi All, I am reading a line from a file and writing it to other file. Whenever I got a particular line then I want that line to be splited into 4 line and written it to new file. e.g My line is U_ABC connector3 pin24E connector4 pin25E connector5 pin26E connector6 pin27E connector7... (2 Replies)
Discussion started by: diehard
2 Replies

2. Shell Programming and Scripting

sed command to grep multiple pattern present in single line and delete that line

here is what i want to achieve.. i have a file with below contents cat fileName blah blah blah . .DROP this REJECT that . --sport 7800 -j REJECT --reject-with icmp-port-unreachable --dport 7800 -j REJECT --reject-with icmp-port-unreachable . . . more blah blah blah --dport 3306... (14 Replies)
Discussion started by: vivek d r
14 Replies

3. Shell Programming and Scripting

Replacing a single line with multiple lines in a file

Hi Am confused with the usage of "sed" command I want to replace a single line with multiple lines of a file.. eg., A file has Hi, How are you? I need to replace as Am fine What are You doing? I used the script as string1="Hi, How are you?" echo "$string1 is the value"... (4 Replies)
Discussion started by: Priya Amaresh
4 Replies

4. Shell Programming and Scripting

convert single line output to multiple line

Hi all, I have a single line output like below echo $ips want to convert above single line output as below format. Pls advice how to do ? Regards Kannan (6 Replies)
Discussion started by: kamauv234
6 Replies

5. UNIX for Dummies Questions & Answers

Multiple Commands on a Single Line

Hi There, I have a cronjob that executes a small script (few lines) that I am certain can be achieved in a single line. The functional objective is actually really simple; cmd var1 The '1' in 'var1' is actually derived from date (day of month) but the snag is when working with 1-9 I... (3 Replies)
Discussion started by: Random79
3 Replies

6. Shell Programming and Scripting

Multiple lines in a single column to be merged as a single line for a record

Hi, I have a requirement with, No~Dt~Notes 1~2011/08/1~"aaa bbb ccc ddd eee fff ggg hhh" Single column alone got splitted into multiple lines. I require the output as No~Dt~Notes 1~2011/08/1~"aaa<>bbb<>ccc<>ddd<>eee<>fff<>ggg<>hhh" mean to say those new lines to be... (1 Reply)
Discussion started by: Bhuvaneswari
1 Replies

7. Shell Programming and Scripting

replace (sed?) a single line/string in file with multiple lines (string) from another file??

Can someone tell me how I can do this? e.g: Say file1.txt contains: today is monday the 22 of NOVEMBER 2010 and file2.txt contains: the 11th month of How do i replace the word NOVEMBER with (5 Replies)
Discussion started by: tuathan
5 Replies

8. Shell Programming and Scripting

How to avoid the truncating of multiple spaces into a single space while reading a line from a file?

consider the small piece of code while read line do echo $line done < example content of example file sadasdasdasdsa erwerewrwr ergdgdfgf rgerg erwererwr the output is like sadasdasdasdsa erwerewrwr ergdgdfgf rgerg erwererwr the... (4 Replies)
Discussion started by: Kesavan
4 Replies

9. Shell Programming and Scripting

make multiple line containing a pattern into single line

I have the following data file. zz=aa azxc-1234 aa=aa zz=bb azxc-1234 bb=bb zz=cc azxc-1234 cc=cc zz=dd azxc-2345 dd=dd zz=ee azxc-2345 ee=ee zz=ff azxc-3456 ff=ff zz=gg azxc-4567 gg=gg zz=hh azxc-4567 hh=hh zz=ii azxc-4567 ii=ii I want to make 2nd field pattern matching multiple lines... (13 Replies)
Discussion started by: VTAWKVT
13 Replies

10. Shell Programming and Scripting

single line input to multiple line output with sed

hey gents, I'm working on something that will use snmpwalk to query the devices on my network and retreive the device name, device IP, device model and device serial. I'm using Nmap for the enumeration and sed to clean up the results for use by snmpwalk. Once i get all the data organized I'm... (8 Replies)
Discussion started by: mitch
8 Replies

Featured Tech Videos