Sponsored Content
Top Forums Shell Programming and Scripting Need help on appending all the lines in a file after a pattern is found Post 302712511 by dev.devil.1983 on Tuesday 9th of October 2012 09:05:05 AM
Old 10-09-2012
Bug Need help on appending all the lines in a file after a pattern is found

Hi Friends,

I am working on a file which has content as follows
Code:
Wed,Database,ABC_cube,loaded
Wed,Logging,out,user,302002654,active,for,0,minutes
Wed,Logging,out,user,109000151,active,for,8,minutes
Wed,Logging,out,user,302002654,active,for,0,minutes
Wed,Logging,out,user,302002654,active,for,60,minutes
Wed,Database,XYZ_cube,loaded
Wed,Logging,out,user,302002654,active,for,0,minutes
Wed,Logging,out,user,109000151,active,for,8,minutes
Wed,Logging,out,user,302002654,active,for,0,minutes
Wed,Logging,out,user,302002654,active,for,60,minutes
Wed,Database,DBC_cube,loaded
Wed,Logging,out,user,302002654,active,for,0,minutes
Wed,Logging,out,user,109000151,active,for,8,minutes
Wed,Logging,out,user,302002654,active,for,0,minutes
Wed,Logging,out,user,302002654,active,for,60,minutes

my requirement is that i want to have the 'cube name' i.e ABC_cube,XYZ_cube at the end of the successive lines as follows
Code:
Wed,Database,ABC_cube,loaded
Wed,Logging,out,user,302002654,active,for,0,minutes,ABC_cube
Wed,Logging,out,user,109000151,active,for,8,minutes,ABC_cube
Wed,Logging,out,user,302002654,active,for,0,minutes,ABC_cube
Wed,Logging,out,user,302002654,active,for,60,minutes,ABC_cube
Wed,Database,XYZ_cube,loaded
Wed,Logging,out,user,302002654,active,for,0,minutes,XYZ_cube
Wed,Logging,out,user,109000151,active,for,8,minutes,XYZ_cube
Wed,Logging,out,user,302002654,active,for,0,minutes,XYZ_cube
Wed,Logging,out,user,302002654,active,for,60,minutes,XYZ_cube
Wed,Database,DBC_cube,loaded
Wed,Logging,out,user,302002654,active,for,0,minutes,DBC_cube
Wed,Logging,out,user,109000151,active,for,8,minutes,DBC_cube
Wed,Logging,out,user,302002654,active,for,0,minutes,DBC_cube
Wed,Logging,out,user,302002654,active,for,60,minutes,DBC_cube

Thanks in advance Smilie

Last edited by Franklin52; 10-09-2012 at 10:50 AM.. Reason: Please use code tags for data and code samples
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

need help appending lines/combining lines within a file...

Is there a way to combine two lines onto a single line...append the following line onto the previous line? I have the following file that contains some blank lines and some lines I would like to append to the previous line... current file: checking dsk c19t2d6 checking dsk c19t2d7 ... (2 Replies)
Discussion started by: mr_manny
2 Replies

2. Shell Programming and Scripting

Delete a block of text delimited by blank lines when pattern is found

I have a file which contains blocks of text - each block is a multi-lines text delimited by blank lines eg. <blank line> several lines of text ... pattern found on this line several more lines of text ... <blank line> How do you delete the block of text (including the blank lines) when... (17 Replies)
Discussion started by: gleu
17 Replies

3. Shell Programming and Scripting

appending lines to a file dynamically

Hi all, I have a file with some number of lines. I need to add certain number of lines from another file which may vary according to the user's input and to it. eg code: I/P file 1 apps/file/xyz apps/file/abc apps/file/def file 2 progs/file/xyz ... (2 Replies)
Discussion started by: Ananthdoss
2 Replies

4. Shell Programming and Scripting

Grouping or appending the lines in a file through Unix

Hi, I am looking for a way to Group the Lines in a file.. Basically My file structure is something like this A 1 100 abc def A 1 200 abc def A 1 300 abc def A 2 100 pqr def A 2 200 pqr def A 2 300 pqr def A 1 100 abc def A 1 200 xyz def A 1 300 xyz def I need it as... (1 Reply)
Discussion started by: mkandula1983
1 Replies

5. UNIX for Dummies Questions & Answers

Grouping or appending the lines in a file through Unix

Hi, I am looking for a way to Group the Lines in a file.. Basically My file structure is something like this A 1 100 abc def A 1 200 abc def A 1 300 abc def A 2 100 pqr def A 2 200 pqr def A 2 300 pqr def A 1 100 abc def A 1 200 xyz def A 1 300 xyz def I need it as... (6 Replies)
Discussion started by: mkandula1983
6 Replies

6. Shell Programming and Scripting

awk to print all lines after a pattern is found

Is there a way with aw to print all lines after a string is found There is a file like this ....... ........ 2012/19/11 :11.58 PM some data lne no date 2012/19/11 :11.59 PM some other data 2012/20/11 :12.00 AM some other data some line without dates some more lines without dates... (8 Replies)
Discussion started by: swayam123
8 Replies

7. Shell Programming and Scripting

Copy/print all lines between pattern is found in .log files

Hi, I have a folder with multiple (< 33) .log files. And I have to copy the lines between two patterns from all the .log files to a new file. (script file with a loop?) Thanks in advance. 1.log ... .. xx1> begin ... .. .. >>> Total: 2 Alarms .. .. (17 Replies)
Discussion started by: AK47
17 Replies

8. Shell Programming and Scripting

If first pattern is found, look for second pattern. If second pattern not found, delete line

I had a spot of trouble coming up with a title, hopefully you'll understand once you read my problem... :) I have the output of an ldapsearch that looks like this: dn: cn=sam,ou=company,o=com uidNumber: 7174 gidNumber: 49563 homeDirectory: /home/sam loginshell: /bin/bash uid: sam... (2 Replies)
Discussion started by: samgoober
2 Replies

9. Shell Programming and Scripting

Appending lines in a file

Hello, I have a file like: str1,"HEX"H,(39),info str2,"HEX"H,(854548),info str3,"HEX"H,'BGTOUR',info str4,"HEX"H,(534322),info str1,"HEX"H,,info str3,"HEX"H,'Landing',info str4,"HEX"H,'BG',info str1,"HEX"H,,info str3,"HEX"H,'Ay',info str1,"HEX"H,(27),info str2,"HEX"H,(854548),info... (2 Replies)
Discussion started by: apenkov
2 Replies

10. UNIX for Beginners Questions & Answers

Sed/awk join lines once pattern found

Hi all OS - RHEL6.4 I have input file -f1.txt I need to search line which starts with \Start and read next line till it gets blank line and join them all. I need to trim any trailing spaces for each line.So output.txt should be.. \Start\now\fine stepwatch this space for toolsends... (7 Replies)
Discussion started by: krsnadasa
7 Replies
RFSTAT(1)							Rfio User Commands							 RFSTAT(1)

NAME
rfstat - get information about a file or directory SYNOPSIS
rfstat directory rfstat filename DESCRIPTION
The rfstat program provides an interface to the shift remote file I/O daemon (rfiod) for getting information about a remote directory or file. The filename or directory argument is either a remote file name of the form: hostname:path or a local file name (not containing the :/ character combination). The output from the rfstat command gives information similar to that of the ls -il command for listing local files or directories, one field per line. EXAMPLE
rfstat /tmp Device : 802 Inode number : 2 Nb blocks : 16 Protection : drwxrwxrwt (41777) Hard Links : 13 Uid : 0 (root) Gid : 0 (root) Size (bytes) : 4096 Last access : Wed Jun 15 07:18:10 2011 Last modify : Wed Jun 15 07:18:10 2011 Last stat. mod. : Wed Jun 15 07:18:10 2011 SEE ALSO
rfio_stat(3), rfiod(1) NOTES
rfstat does not support regular expressions (regexp(5)) in the directory or filename argument. AUTHOR
LCG Grid Deployment Team LCG
$Date$ RFSTAT(1)
All times are GMT -4. The time now is 10:24 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy