Sponsored Content
Top Forums Shell Programming and Scripting Insert specific line when found similar value Post 302593433 by attila on Thursday 26th of January 2012 11:41:12 PM
Old 01-27-2012
Insert specific line when found similar value

Hi All,

I have file like this:

file1:

Code:
3778 10474 24
3778 10475 24
3778 10476 25
3778 10495 26
3794 10001 33
3794 10002 33
3794 10004 33
3794 10007 34
3794 10008 34
3794 10011 34
3794 10012 34
3794 10013 34
3794 10017 34
3810 10282 27
3810 10283 27
3810 10284 27
3810 10285 27
3810 10286 27
3810 10287 27
3810 10288 27
3906 10154 34
3906 10155 34
3906 10156 34
3906 10157 34

output that I want :
Code:
                              LINE  3778 ,
                              10474 =  24 ,
                              10475 =  24 ,
                              10476 =  25 ,
                              10495 =  26 ,
                              LINE  3794 ,
                              10001 =  33 ,
                              10002 =  33 ,
                              10004 =  33 ,
                              10007 =  34 ,
                              10008 =  34 ,
                              10011 =  34 ,
                              10012 =  34 ,
                              10013 =  34 ,
                              10017 =  34 ,  
                              LINE  3794 ,
                              10282 =  27 ,
                              10283 =  27 ,
                              10284 =  27 ,
                              10285 =  27 ,
                              10286 =  27 ,
                              10287 =  27 ,
                              10288 =  27 ,
                              LINE  3906 ,
                              10154 =  34 ,
                              10155 =  34 ,
                              10156 =  34 ,
                              10157 =  34 ,

Thanks in advance
- Attila
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Insert blank line if grep not found

Hello everyone... please help if you can -- I'm stumped. Making this work will save me hours of manual labor: I need to search file2 for pattern in file1. If pattern found append file2 line to file3. If pattern not found append a blank line to file3. file1 contents example: 123 456 789... (6 Replies)
Discussion started by: michieka
6 Replies

2. Shell Programming and Scripting

insert new line at found chars

Hey gang, I have: XXZZXXZZXX 123 asdaffggh dfghyrgr ertyhdhh XXZZXXZZXX 234 sdg XXZZXXZZXX 456 gfg fggfd That is all on one line. Very simply put I want to do is something like: sed s'/XXZZXXZZXX /\n/g' or tr 'XXZZXXZZXX ' '/n' I have tried various things but can never get the desired... (6 Replies)
Discussion started by: crowman
6 Replies

3. Shell Programming and Scripting

search a line and insert string into specific at position

Hi, guys. I have one question: How can I search for a line with certain string in it and then insert a string into this line? For example: There is a file called shadow, the contents of it are below: ************************** ... yuanz:VIRADxMsadfDF/Q:0:0:50:7:::... (9 Replies)
Discussion started by: daikeyang
9 Replies

4. Shell Programming and Scripting

Insert blank line if grep not found

Hi all, I've googling around forum regarding my prob, the nearest would same as thread tittled Insert blank line if grep not found, but she/he did not mention the solution, so I would like to request your help I've this task, to search in file2 based on pattern in file1 and output it to... (4 Replies)
Discussion started by: masterpiece
4 Replies

5. Shell Programming and Scripting

Korn Shell script to insert at specific line

Hi, I am trying to put together a Korn Shell script to insert at a specific line. The system we use is SunOS 5.10 I can get the line number by using:- num=`sed -n '/export ENV/=' ./tmp.file` Not getting much headway using the above variable's value to insert - export SYBASE=/opt/sybase15... (5 Replies)
Discussion started by: aj8200
5 Replies

6. UNIX for Dummies Questions & Answers

insert string at end of line if it found from list

Hi all, can some one help me out file 1 i have 06/01 3:14 d378299 06/01 8:10 d642036 06/01 10:51 d600441 06/01 10:52 d600441 06/01 11:11 d607339 06/01 11:49 d398706 something like this and in file named list i have ( there is space btwn 06/01 and 11:49 and d398706) d607339... (5 Replies)
Discussion started by: zozoo
5 Replies

7. Solaris

Insert a file at specific line

Hi, Anyone can help me in Solaris command on how to insert a file at specific line. I want file1.sql content to be inserted on file2.sh after "recover database using backup controlfile until cancel". # file1.sql /archivelogs/927_822338133.arc /archivelogs/671_822338107.arc... (3 Replies)
Discussion started by: fspalero
3 Replies

8. Shell Programming and Scripting

Insert line based on found string

Hi All I'm trying to insert a new line at the before each comment line in a file. Comment lines start with '#-----' there are other comments with in lines but I don't want a new line there. Example file: blah blah #do not insert here #this is a comment blah #some more #another comment... (10 Replies)
Discussion started by: Mudshark
10 Replies

9. Shell Programming and Scripting

Insert character at specific location in a each line of the file

Hi All, I am trying to write a shell script where it should insert character 'I' in 180th position of each line(except first and last line) of the file. Below is the script for file in /home/test/bharat/*.RET do # Process file echo "File Name=" $file #l_fileName="${file##*/}" ... (19 Replies)
Discussion started by: bharath561989
19 Replies

10. UNIX for Beginners Questions & Answers

How to insert new line after a specific character in scripts?

Hi, I'm trying to add a new line after finding a specific String. That is my string: volumes: - ${DIR_WORK}/loadbalancer/html:/var/www/html and I want to change that file to: volumes: - ${DIR_WORK}/loadbalancer/html:/var/www/html extra_hosts: -... (4 Replies)
Discussion started by: siamak
4 Replies
gnokiid(8)							      gnokii								gnokiid(8)

NAME
gnokiid - create a virtual modem for old Nokia mobile phones SYNOPSIS
gnokiid gnokiid [--help|--version|--debug] DESCRIPTION
gnokiid is a tool from the gnokii tool suite used to create a virtual modem device with a Nokia portable telephone. The virtual modem device is usually accessed via a symbolic link called /dev/gnokii (created automatically by mgnokiidev(8)). Please note that you don't need a virtual modem when you have real modem accepting AT Hayes commands (most of the modern phones). gnokiid was written for the phones that supported data transfer but didn't expose AT layer (namely Nokia 6110, 6130, 6150, 5110, 5130). After gnokiid has created the virtual modem, it can be accessed like any other Hayes-compatible modem by such programs as the terminal pro- gram minicom(1) or the PPP daemon pppd(8) to make standard data connections to remote computers. The full range of portable telephone functions (SMS messaging, phone book, operator logos, etc.) are accessed using the command-line pro- gram gnokii(1) or the graphical interface program xgnokii(1x). gnokii is a Linux/Unix tool suite and (eventually) modem/fax driver for Nokia mobile phones, released under the GPL. gnokii supports most phones from the 3810/8110 and 5110/6110 series, details including bugs specific to each series appear in the files Docs/README-3810 and Docs/README-6110 respectively. OPTIONS
If called without any options, gnokiid will set up a virtual modem device using the settings in gnokii(1) config file (if it exists). Oth- erwise, --help print out a short usage message --version print out version, copyright, phone, and serial device info --debug uses STDIN/STDOUT for a virtual modem DIAGNOSTICS
Various error messages are printed to STDERR. BUGS
Hmmm... AUTHOR
Hugh Blemings <hugh at blemings dot org> and Pavel Janik ml. <Pavel.Janik at suse dot cz> are the authors of the gnokii tool suite. This manual page was written by Erik Rossen <rossen at freesurf dot ch>. See also Docs/CREDITS from the gnokii sources. COPYING
This program is distributed under the GNU Public License Version 2, or (at your option) any later version.. SEE ALSO
gnokii, xgnokii, mgnokiidev Erik Rossen May 27, 2001 gnokiid(8)
All times are GMT -4. The time now is 08:58 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy