From multiple line to one line to multiple line


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting From multiple line to one line to multiple line
# 1  
Old 09-03-2008
From multiple line to one line to multiple line

Hi!

I'm using this code

Code:
grep "[0-9\.\-].* [0-9\.\-].* [0-9\.\-].*" $FILENAME >> $REPORT

to get 3D coordinates from a file (FILENAME) like this one :

Code:
0.1 0.1 0.1
2 2 2
0.03 0.03 0.03
...

and then write the coordinates in REPORT. The problem is that all lines from FILENAME appear on the same line in REPORT...

Anyone have an idea how I can copy these coordinates from one file to the other keeping track of the line by line structure?

Thanks a lot!

Tipi
# 2  
Old 09-03-2008
try sed..
# 3  
Old 09-03-2008
Quote:
Originally Posted by tipi
Hi!

I'm using this code

Code:
grep "[0-9\.\-].* [0-9\.\-].* [0-9\.\-].*" $FILENAME >> $REPORT

to get 3D coordinates from a file (FILENAME) like this one :

Code:
0.1 0.1 0.1
2 2 2
0.03 0.03 0.03
...

and then write the coordinates in REPORT. The problem is that all lines from FILENAME appear on the same line in REPORT...

Anyone have an idea how I can copy these coordinates from one file to the other keeping track of the line by line structure?

Thanks a lot!

Tipi
Give a sample input and outfile
# 4  
Old 09-03-2008
Thank you all for your answers.

Quote:
Originally Posted by dennis.jacob
Give a sample input and outfile
I already gave a input file sample. As I said, the output file from my command is the same as the input, except that everything is on one single line.
# 5  
Old 09-03-2008
Quote:
Originally Posted by vidyadhar85
try sed..
I'm looking in my unix reference book...
# 6  
Old 09-03-2008
Ok, this do exactly what I want

sed -n 's/[0-9\.\-].* [0-9\.\-].* [0-9\.\-].*/&/w $REPORT' <$FILENAME

Thanks for help,

Tipi
# 7  
Old 09-03-2008
I am not getting the kind of output which you got as you mentioned with your code..

Anyway try this:

Code:
awk '/[0-9\.\-].* [0-9\.\-].* [0-9\.\-].*/ { print $0 "\n"; }' filename

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Perl command line option '-n','-p' and multiple files: can it know a file name of a printed line?

I am looking for help in processing of those options: '-n' or '-p' I understand what they do and how to use them. But, I would like to use them with more than one file (and without any shell-loop; loading the 'perl' once.) I did try it and -n works on 2 files. Question is: - is it possible to... (6 Replies)
Discussion started by: alex_5161
6 Replies

2. Shell Programming and Scripting

How to print previous line of multiple pattern matched line?

Hello, I have below format log file, Comparing csv_converted_files/2201/9747.1012H67126.5077292103609547345.csv and csv_converted_files/22019/97447.1012H67126.5077292103609547345.csv Comparing csv_converted_files/2559/9447.1012H67126.5077292103609547345.csv and... (6 Replies)
Discussion started by: arvindshukla81
6 Replies

3. Shell Programming and Scripting

Multiple line search, replace second line, using awk or sed

All, I appreciate any help you can offer here as this is well beyond my grasp of awk/sed... I have an input file similar to: &LOG &LOG Part: "@DB/TC10000021855/--F" &LOG &LOG &LOG Part: "@DB/TC10000021852/--F" &LOG Cloning_Action: RETAIN &LOG Part: "@DB/TCCP000010713/--A" &LOG &LOG... (5 Replies)
Discussion started by: KarmaPoliceT2
5 Replies

4. 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

5. Shell Programming and Scripting

Merge multiple lines to one line when line starts with and ends with

example: comment Now_TB.table column errac is for error messages 1 - first 2 - second 3 -third ; in this example I need to be able to grab the comment as first word and ; as the last word and it might span a few lines. I need it to be put all in one line without line breaks so I can... (4 Replies)
Discussion started by: wambli
4 Replies

6. Shell Programming and Scripting

convert single line output to multiple line

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

7. Shell Programming and Scripting

Shell script to read multiple options from file, line by line

Hi all I have spent half a day trying to create a shell script which reads a configuration file on a line by line basis. The idea of the file is that each will contain server information, such as IP address and various port numbers. The line could also be blank (The file is user created). Here... (1 Reply)
Discussion started by: haggismn
1 Replies

8. Shell Programming and Scripting

KSH: Reading a file line by line into multiple arrays

Hi - I have a file that contains data in this format:- #comment value1 value2 value3 #comment value4 value5 value6 value7 #comment value8 value9 I need to read value1, value2 and value3 into one array, value4 value5 value6 and value7 into another array and value8 and value9 into a 3rd... (2 Replies)
Discussion started by: sniper57
2 Replies

9. Shell Programming and Scripting

Compare multiple fields in file1 to file2 and print line and next line

Hello, I have two files that I need to compare and print out the line from file2 that has the first 6 fields matching the first 6 fields in file1. Complicating this are the following restrictions 1. file1 is only a few thousand lines at most and file2 is greater than 2 million 2. I need to... (7 Replies)
Discussion started by: gillesc_mac
7 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
Login or Register to Ask a Question