Find and change the lines in the file.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Find and change the lines in the file.
# 1  
Old 11-02-2011
Find and change the lines in the file.

Hi Everyone,

I have a JIL (Job Information Language) Definition for Several Jobs in a file.
I would like to do the following:

Code:
insert_job: KS_INT_BIZ_INT   job_type: c
command: /home/filter/script.sh INT
machine: MACHINE
owner: filter
permission: gx,mx
date_conditions: 1
days_of_week: all
start_times: "12:00"
description: "REGION"
std_out_file: /home/filter/logs/KS_INT_BIZ_INT.`date +%Y%m%d`.log
std_err_file: /home/filter/logs/KS_INT_BIZ_INT_err.`date +%Y%m%d`.log
max_run_alarm: 30
alarm_if_fail: 1
profile: /home/filter/.autosys_profile
timezone: US/Eastern

...so on

So, i am trying to do the following for the command field i.e.:

Code:
command: echo " /home/filter/script.sh INT "

So If the command field exists then I need to include the echo " <whatever the field has > " in the command filed.

Could someone please tell me a nice / easier way to do this.

Really appreciate your help and thoughts on this.
# 2  
Old 11-02-2011
Code:
sed 's#^command:\(.*\)#command: echo " \1 "#' myJILfile

This User Gave Thanks to vgersh99 For This Post:
# 3  
Old 11-03-2011
With awk..
Code:
awk -F: '/command: /{print $1 FS " echo \"" $2 " \" ";next}1' inputfile

This User Gave Thanks to michaelrozar17 For This Post:
# 4  
Old 11-03-2011
thanks a lot for your quick replies.

Appreciate your help.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Find all lines in file such that each word on that line appears in at least n lines of the file

I have a file where every line includes four expressions with a caret in the middle (plus some other "words" or fields, always separated by spaces). I would like to extract from this file, all those lines such that each of the four expressions containing a caret appears in at least four different... (9 Replies)
Discussion started by: uncleMonty
9 Replies

2. Shell Programming and Scripting

Read a lis, find items in a file from the list, change each item

Hello, I have some tab delimited text data, file: final_temp1 aname val NAME;r'(1,) 3.28584 r'(2,)<tab> NAME;r'(3,) 6.13003 NAME;r'(4,) 4.18037 r'(5,)<tab> You can see that the data is incomplete in some cases. There is a trailing tab after the first column for each incomplete row. I... (2 Replies)
Discussion started by: LMHmedchem
2 Replies

3. Shell Programming and Scripting

[awk] find pattern, change next two lines

Hi, hope you can help me... It seems like a straightforward problem, but I haven't had any success so far using my basic scripting and awk "skills": I need to find a pattern /VEL/ in an input file that looks like this: 1110SOL OW25489 1.907 7.816 26.338 -0.4365 0.4100 -0.0736 ... (3 Replies)
Discussion started by: origamisven
3 Replies

4. Shell Programming and Scripting

Trying to take file numbers from a file, pass them to sed to change strings in corresponding lines

I have a bunch of file numbers in the file 'test': I'm trying the above command to change all the instances of "H" to "Na+" in the file testsds.pdb at the line numbers indicated in the file 'test'. I've tried the following and various similar alternatives but nothing is working: cat test |... (3 Replies)
Discussion started by: crunchgargoyle
3 Replies

5. Shell Programming and Scripting

To change Specific Lines in An XML file

hi Guys, this is my requirement, there is a huge xml file of this i have to change 3 lines with out opening the file /users/oracle > cat lnxdb-pts-454.xml|egrep "s_virtual|s_cluster|s_dlsnstatus" <cluster_port oa_var="s_clusterServicePort">9998</cluster_port> <host... (2 Replies)
Discussion started by: smarlaku
2 Replies

6. Shell Programming and Scripting

How to change a number on a specific lines in a file with shell?

Hello My problem is that I want to change some specific numbers in a file. It is like, 2009 10 3 2349 21.3 L 40.719 27.388 10.8 FRO 7 0.8 1.1LFRO 2.6CFRO 1.1LMAM1 GAP=157 1.69 5.7 5.9 5.8 0.5405E+01 0.4455E+00 0.1653E+02E STAT SP IPHASW D HRMM SECON CODA AMPLIT... (11 Replies)
Discussion started by: miriammiriam
11 Replies

7. UNIX for Dummies Questions & Answers

find lines in another file based on contents in a second file

Hello, I have a file with tab delimited columns like: File1 A 2 C R F 4 D Q C 9 A B ...... I want to grep out the lines in a second file, File2, corresponding to each line in File1 Can I do this: while read a b c d do grep '$a\t$b\t$c\t$d' File2 >>... (2 Replies)
Discussion started by: Gussifinknottle
2 Replies

8. UNIX for Dummies Questions & Answers

find lines from one file in the other and print them

Hi guys, please help me to make a loop! I have two files. File 1 2 4 7 File2 1 abc 2 cde 3 ghgj 4 kjhn 5 mbm 6 hghj 7 hgjk I need to write a script that reads lines from File1, finds them in File2 and puts in File3, so File3 should look like this: (3 Replies)
Discussion started by: coppuca
3 Replies

9. UNIX for Dummies Questions & Answers

Script to change/find/delete/install a specific file

Hi Very much a newbie to UNIX & scripting, but have identified an area within work that would benefit from being automated, as its repeated manually very often, and it looks like the ideal first script! What I need to do is change directory to a users home (cd ~), and then find and remove a... (6 Replies)
Discussion started by: Great Uncle Kip
6 Replies

10. Shell Programming and Scripting

find string, then get the next 3 lines in a file

Hi all. HPUX - /bin/sh (posix) I am parsing a 3 field flat file, space deliminted example data.file acct dining mem open 0 50 dep 50 0 close 255 0 acct plus mem open 100 100 dep 50 0 close 323 0 I would like to find strings, then write the next 3 lines out to another file ... (8 Replies)
Discussion started by: lyoncc
8 Replies
Login or Register to Ask a Question