Sponsored Content
Top Forums Shell Programming and Scripting how to print the certain lines in a file to different files Post 302383484 by natalie23 on Wednesday 30th of December 2009 02:22:28 AM
Old 12-30-2009
Hi Ygor,

Can you please explain the code?

May I know why need to have "$3" when redirect the file?

Besides I have tried the code, but in each file I just have the output of <wt> tag

I just modify abit


Code:
awk  ' BEGIN {FS="[<>]"} 
/<ct>/{c=$0}/<name>/{n=$0}/<value>/{printf("%s\n%s\n%s\n</ct>\n",c,n,$0)>"file" $3}/<wt>/{print $0>"file" ++c}' file

The output that I get:

0
<wt>a</wt>

1
<wt>b</wt>

2
<wt>c</wt>

3
<ct>
<name>group</name>
<value>1</value>
<ct>
<name>group</name>
<value>2</value>
<ct>
<name>group</name>
<value>13</value>

Thanks,

Last edited by natalie23; 12-30-2009 at 04:51 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

print the first 5 lines in which 2 files differs

it is a simple problem, but I am totally new to shell programming There are 2 files. I have to print the 5 five lines which are different. I appreciate any help. 10x. (2 Replies)
Discussion started by: atticus
2 Replies

2. Shell Programming and Scripting

print lines AFTER lines cointaining a regexp (or print every first and fourth line)

Hi all, This should be very easy but I can't figure it out... I have a file that looks like this: @SRR057408.1 FW8Y5CK02R652T length=34 AGCAGTGGTATCAACGCAGAGTAAGCAGTGGTAT +SRR057408.1 FW8Y5CK02R652T length=34 FIIHFF6666?=:88@@@BBD:::?@ABBAAA>8 @SRR057408.2 FW8Y5CK02TBMHV length=52... (1 Reply)
Discussion started by: kmkocot
1 Replies

3. Shell Programming and Scripting

extract nth line of all files and print in output file on separate lines.

Hello UNIX experts, I have 124 text files in a directory. I want to extract the 45678th line of all the files sequentialy by file names. The extracted lines should be printed in the output file on seperate lines. e.g. The input Files are one.txt, two.txt, three.txt, four.txt The cat of four... (1 Reply)
Discussion started by: yogeshkumkar
1 Replies

4. Shell Programming and Scripting

AWK print lines into multiple files

Hi, i have an input text file like this: Student 1 maths science = Student 2 maths science = Student 3 maths science i would like to print each student information into separate files, each student id is separated by "=". (1 Reply)
Discussion started by: saint2006
1 Replies

5. UNIX for Dummies Questions & Answers

Compare 2 files print the lines of file 2 that contain a string from file 1

Hello I am a new unix user, and I have a work related task to compare 2 files and print all of the lines in file 2 that contain a string from file 1 Note: the fields are in different columns in the files. I suspect the is a good use for awk? Thanks for your time & help File 1 123 232 W343... (6 Replies)
Discussion started by: KevinRidley
6 Replies

6. Shell Programming and Scripting

Look up between 2 files and print matching lines

Hi, I have 2 large log files in .gz format file 1 contains abcde 12345 23456 . . . . . . . . 09123 (8 Replies)
Discussion started by: aravindj80
8 Replies

7. Shell Programming and Scripting

Print first 20 lines from all .log files

RHEL 5.8 In a directory I have more than 200 files with the extension .log Using head command I want to print first 20 lines of each log file. For each .log file, it should print like below Printing first 20 lines of : GRP_error_April29.log Apr 29 04:02:05 raptor03b syslogd 1.4.1:... (4 Replies)
Discussion started by: John K
4 Replies

8. Shell Programming and Scripting

Print n lines from top and n lines from bottom of all files with .log extenstion

Oracle Linux 6.4 In a directory I have more than 300 files with the extension .log I want the first 5 and last 5 lines of these .log files to be printed on screen with each file's name. Expected output : Printing first 5 and last 5 lines of FX_WT_Feb8_2014.log !! Authentication... (7 Replies)
Discussion started by: kraljic
7 Replies

9. UNIX for Beginners Questions & Answers

Print number of lines for files in directory, also print number of unique lines

I have a directory of files, I can show the number of lines in each file and order them from lowest to highest with: wc -l *|sort 15263 Image.txt 16401 reference.txt 40459 richtexteditor.txt How can I also print the number of unique lines in each file? 15263 1401 Image.txt 16401... (15 Replies)
Discussion started by: spacegoose
15 Replies

10. UNIX for Beginners Questions & Answers

How to print lines from a files with specific start and end patterns and pick only the last lines?

Hi, I need to print lines which are matching with start pattern "SELECT" and END PATTERN ";" and only select the last "select" statement including the ";" . I have attached sample input file and the desired input should be as: INPUT FORMAT: SELECT ABCD, DEFGH, DFGHJ, JKLMN, AXCVB,... (5 Replies)
Discussion started by: nani2019
5 Replies
LVGROUP(3PVM)							  PVM Version 3.4						     LVGROUP(3PVM)

NAME
pvm_lvgroup - Unenrolls the calling process from a named group. SYNOPSIS
C int info = pvm_lvgroup( char *group ) Fortran call pvmflvgroup( group, info ) PARAMETERS
group Character string group name of an existing group. info Integer status code returned by the routine. Values less than zero indicate an error. DESCRIPTION
The routine pvm_lvgroup unenrolls the calling process from the group named group. If there is an error info will be negative. If a process leaves a group by calling either pvm_lvgroup or pvm_exit, and later rejoins the same group, the process may be assigned a new instance number. Old instance numbers are reassigned to processes calling pvm_joingroup. EXAMPLES
C: info = pvm_lvgroup( "worker" ); Fortran: CALL PVMFLVGROUP( 'group2', INFO ) ERRORS
These error conditions can be returned by pvm_lvgroup PvmSysErr pvmd not responding. PvmBadParam giving a NULL group name. PvmNoGroup giving a non-existent group name. PvmNotInGroup asking to leave a group you are not a member of. SEE ALSO
pvm_joingroup(3PVM) 30 August, 1993 LVGROUP(3PVM)
All times are GMT -4. The time now is 05:07 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy