07-26-2012
Thanks for soln. I figured out one way to d it myself:
awk -F "\t" -v drv=$mod_pat '$3 ~ drv { OFS= "\t"; $6 = " happy_home"; print;}' sample
---------- Post updated at 06:34 PM ---------- Previous update was at 06:19 PM ----------
I got caught in the else part of condition:
Below I am checking if field 3 matches the pattern specified by drv do whatever next in braces {}
awk -F "\t" -v drv=$mod_pat '$3 ~ drv { OFS= "\t"; $6 = " happy_home"; print;}' sample
The problem now is I want to just print the line untouched if the pattern is not matched. Is this possible in the same command ?
I tried:
awk -F "\t" -v drv=$mod_pat ' if ($3 ~ drv) { OFS= "\t"; $6 = " happy_home"; print;} else {print;}' sample.rpt
But its throwing parse error. Probably some problem with awk syntax.
Any help will be appreciated.
Thanks
---------- Post updated at 09:00 PM ---------- Previous update was at 06:34 PM ----------
Anyhelp ? is this thread closed ??
---------- Post updated at 09:39 PM ---------- Previous update was at 09:00 PM ----------
Thanx anyways, got it:
This works:
awk -F "\t" -v drv=$mod_pat '{ if ($3 ~ drv) { OFS= "\t"; $6 = " happy_home"; print;} else {print;} }' sample.rpt
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
HI all
I have a problem, I need to replace a field in a file, but only in the lines that have some pattern, example:
100099C01101C00000000059394200701CREoperadora_TX
100099C01201C00000000000099786137OPERADORA_TX2
in the example above I need to change the first field from 1 to 2 only if... (3 Replies)
Discussion started by: sergiioo
3 Replies
2. Shell Programming and Scripting
can some one help me with a perl command
i have to search and replace a version from a xml-file
so i use in a ksh script a command like this
ssh $GLB_ACC@$GLB_HOST "/usr/contrib/bin/perl -pi -e "s/$curVersion/$new_Version/g" $Dest_dir/epi.xml"
this command worked so far, but the problem... (1 Reply)
Discussion started by: kiranreddy1215
1 Replies
3. UNIX for Dummies Questions & Answers
My requirement is to replace a a particular pattren in a script from A to B.
I am not sure if this can be done through sed command or through awk .
The file sv.inc is
window DialogBox AddConnection
tag "~ActiveApp/Add Connection - Provider Type?URL"
I would wnat the file to be... (10 Replies)
Discussion started by: bsandeep_80
10 Replies
4. Shell Programming and Scripting
Frds
I have to search for a string which is starting with brighton which will be first in the line of a text file test1.txt. The contents of test1.txt are file names like
-----
brighton
brighton_gt
hst_brighton
gst_brighton
-------so many files------
---------
i have retrieve only... (3 Replies)
Discussion started by: KiranKumarKarre
3 Replies
5. UNIX for Dummies Questions & Answers
Hi,
I am trying to find a particular patter in multiple UNIX files (also contain system files,hidden files and normal files)
i am now using
CMD: egrep -ali 'pattern' *
i am not getting the required result, i just need files path and finename
Naveen (3 Replies)
Discussion started by: Naveen_5960
3 Replies
6. Shell Programming and Scripting
Hi,
I have a date/time field in my file. I have to search in all the records and append a timestamp to it, if the timestamp is missing in that field. Is there a possible awk solution for this?
Field date format
File1
====
1|vamu|payer|2007-12-02 02:01:30|bcbs|... (5 Replies)
Discussion started by: machomaddy
5 Replies
7. UNIX for Dummies Questions & Answers
Hi !
I have a tab-delimited file, file.tab:
Column1 Column2 Column3
aaaaaaaaaa bbtomatoesbbbbbb cccccccccc
ddddddddd eeeeappleseeeeeeeee ffffffffffffff
ggggggggg hhhhhhtomatoeshhh iiiiiiiiiiiiiiii
... (18 Replies)
Discussion started by: lucasvs
18 Replies
8. Shell Programming and Scripting
Hi,
I want a script which search for a pattern "good" in a huge file and provide me number of occurences of such pattern in a file.
lets say i have a file test.txt contents as below
good is good
but good is sometime bad and sometime good
you are very good and good is always good
... (7 Replies)
Discussion started by: sv0081493
7 Replies
9. Shell Programming and Scripting
$ cat /cygdrive/d/Final2.txt
1,A ,Completed, 07.03_23.01 ,Jun 30 20:00
2,BBB,Pending,,
3,CCCCC,Pending,,
4,DDDDD,Pending,,
5,E,Pending,,
6,FFFF,Pending,,
7,G,Pending,,
In the above file 4th field is date which is in MM.DD_HH.MIN format and I need to convert it to as it is there in 5th... (1 Reply)
Discussion started by: Amit Joshi
1 Replies
10. Shell Programming and Scripting
I have posted this again as old post is closed and I am not able to reopen. so please consider this new post
Input File :
1,A,Completed,06.02_19.36,Jun 30 20:00
2,BBB,Failed,07.04_05.12,Jul 21 19:06
3,CCCCC,New,07.21_03.03,Jul 26 12:57
4,DDDDD,Pending,,
I wast output file as:
... (7 Replies)
Discussion started by: Amit Joshi
7 Replies
drv(1) Apple Inc. drv(1)
NAME
drv - cups driver interface for ppd compiler files
SYNOPSIS
drv list
drv cat drv:///filename.drv/pcfilename
DESCRIPTION
drv lists and compiles PPDC source files installed in the /usr/share/cups/drv and (on Mac OS X) /Library/Printers/PPDs/Contents/Resources
directories on behalf of the scheduler, cupsd(8).
The first form of the command lists all of the PPD files that can be produced by the driver information files in the two directories.
The second form of the command compiles the requested PPD and sends it to the standard output.
SEE ALSO
ppdc(1), ppdhtml(1), ppdi(1), ppdmerge(1), ppdpo(1), ppdcfile(5)
http://localhost:631/help
COPYRIGHT
Copyright 2008-2009 by Apple Inc.
9 March 2009 CUPS drv(1)