Read the lines within file and send each line to different new file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Read the lines within file and send each line to different new file
# 1  
Old 02-12-2010
Read the lines within file and send each line to different new file

I need help.....I have number of data files and I need to read the contains of each file which is three lines by awk commands or script, and send each line within the data file to different new file . That means I will have three files as a result, the first file will contains the first lines for all the data files , the second file will contain the second lines for all the data files and so on.

---------- Post updated at 08:15 AM ---------- Previous update was at 08:02 AM ----------

I am waiting for some one to help me
# 2  
Old 02-12-2010
Hi.

Maybe this will help you: The Forum Rules.

Quote:
(4) Do not 'bump up' questions if they are not answered promptly. No duplicate or cross-posting and do not report a post or send a private message where your goal is to get an answer more quickly.
# 3  
Old 02-12-2010
I am very sorry for that
# 4  
Old 02-12-2010
Code:
$ awk '{ print > "file_" FNR }' file1 file2 file3

$ cat file[123]
f1
f2
f3

a1
a2
a3

q1
q2
q3

$ cat file_[123]
f1
a1
q1

f2
a2
q2

f3
a3
q3

# 5  
Old 02-14-2010
Hi
THanks. I have tried to apply those commandes to extract the data, but I need more explenation to apply it for larg number of data files ( each file have three lines of data which send to the different three result files line1, line2 line3 to file1 file2 file3)and the same three number of result files.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Read the file line by line and do something with lines

I have a file file_name_O.txt The file can have different number of other files names or nothing I will check cnt=`wc -l file_name_0.txt` if ;then exit 1 fi Now I have to start checking file names, i.e. read txt file line by line. If amount of ,lines equal 1, I can... (4 Replies)
Discussion started by: digioleg54
4 Replies

2. Shell Programming and Scripting

Read file lines and pass line values as arguments.

Dears, Need help to implement below requirement A file (detail.txt)contain : 1st column: Stream 2nd column: PathAddress 3rd column: Counterlimit 4th column: TransactionDateColumn 5th column: DateType 6th column: SleepValue 7th column: Status Need to write a... (1 Reply)
Discussion started by: sadique.manzar
1 Replies

3. Shell Programming and Scripting

Read file data and send to different file

junk.txt has a single numerical value in it, let's say 50421.44. over.namelist has lots of expressions in it, but somewhere random it says value = x.x I need to go into junk.txt, pull out the number, and amend over.namelist to say value = 50421.44. :(:( I'm trying to use sed, but... (5 Replies)
Discussion started by: jammyjames
5 Replies

4. Shell Programming and Scripting

Need a program that read a file line by line and prints out lines 1, 2 & 3 after an empty line...

Hello, I need a program that read a file line by line and prints out lines 1, 2 & 3 after an empty line... An example of entries in the file would be: SRVXPAPI001 ERRO JUN24 07:28:34 1775 REASON= 0000, PROCID= #E506 #1065: TPCIPPR, INDEX= 003F ... (8 Replies)
Discussion started by: Ferocci
8 Replies

5. Shell Programming and Scripting

Bash script to send lines of file to new file based on Regex

I have a file that looks like this: cat includes CORP-CRASHTEST-BU e:\crashplan\ CORP-TEST /usr/openv/java /usr/openv/logs /usr/openv/man CORP-LABS_TEST /usr/openv/java /usr/openv/logs /usr/openv/man What I want to do is make three new files with just those selections. So the three... (4 Replies)
Discussion started by: newbie2010
4 Replies

6. Shell Programming and Scripting

Read file and send email

I have a file like this. I need to ues this file to send emails to the appropriate ID/group. For instance in the first line - Subject should be --> "A1.csv - ABC" - Body should be --> File A1.csv has changed. - Email should be sent to A1@xyz.com,A3@xyz.com Lookup.csv: ... (1 Reply)
Discussion started by: vskr72
1 Replies

7. Shell Programming and Scripting

read one line file and separate into multiple lines

I have one long line text with semicolon used as separator between values in that line. Now, I want to separate the line into multiple line right after every 29th field. example input line: ... (1 Reply)
Discussion started by: erlanq
1 Replies

8. Shell Programming and Scripting

read one line file and separate into multiple lines

I have one long line text with semicolon used as separator between values in that line. Now, I want to separate the line into multiple line right after every 29th field. example input line: ... (2 Replies)
Discussion started by: erlanq
2 Replies

9. Shell Programming and Scripting

bash: read file line by line (lines have '\0') - not full line has read???

I am using the while-loop to read a file. The file has lines with null-terminated strings (words, actually.) What I have by that reading - just a first word up to '\0'! I need to have whole string up to 'new line' - (LF, 10#10, 16#A) What I am doing wrong? #make file 'grb' with... (6 Replies)
Discussion started by: alex_5161
6 Replies

10. Shell Programming and Scripting

shell script to read a line in gps receiver log file and append that line to new file

Hi, I have gps receiver log..its giving readings .like below Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. GPSD,R=1 $GPGSV,3,1,11,08,16,328,40,11,36,127,00,28,33,283,39,20,11,165,00*71... (3 Replies)
Discussion started by: gudivada213
3 Replies
Login or Register to Ask a Question