![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| search excat string in another string (grep "fails") | bora99 | UNIX for Dummies Questions & Answers | 0 | 06-05-2008 03:41 AM |
| Search, replace string in file1 with string from (lookup table) file2? | gstuart | Shell Programming and Scripting | 2 | 04-11-2008 11:32 AM |
| Perl: Search for string on line then search and replace text | Crypto | Shell Programming and Scripting | 4 | 01-04-2008 07:24 AM |
| Search for a string | sumesh.abraham | Shell Programming and Scripting | 12 | 12-11-2006 06:29 AM |
| appending string to text file based on search string | malaymaru | Shell Programming and Scripting | 1 | 06-09-2006 05:53 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
search string
Hi ,
I need to right a script in which I need to search for a string, which is at 11th column fields saperated by "|" and delete all the lines from the file which contains that string . Please help |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
Dear viv1,
try this awk -F'|' 'BEGIN{ while(getline < "filename1") { if ( $11 != <SEARCH STRING>) { print $0 } } }' >> filename2 filename1 will be ur input file and filename2 will be ur output file in which u'll redirect the output. "SEARCH STRING" will be the string u want to search for. Regards, Pankaj |
|
#3
|
|||
|
|||
|
u can do it in one line also
awk -F'|' 'BEGIN{while(getline < "filename1"){if ( $11 != <SEARCH STRING>){print $0}}}' >> filename2 Regards, Pankaj |
|
#4
|
|||
|
|||
|
Code:
# awk -F"|" s="$searchstring" '$11!=s' file |
|||
| Google The UNIX and Linux Forums |