![]() |
|
|
|
|
|||||||
| 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 |
| How to rewrite a line in a file | c0384 | Shell Programming and Scripting | 21 | 05-21-2007 11:06 PM |
| How do I rewrite to use a while instead of find? | goodmis | Shell Programming and Scripting | 4 | 02-06-2007 11:20 AM |
| Make grep -c display like grep -n? | Jerrad | Shell Programming and Scripting | 2 | 08-24-2006 09:20 PM |
| rewrite the same info in 3 different files | strok | Shell Programming and Scripting | 6 | 03-29-2003 10:50 AM |
| Apache Rewrite help! | hassan2 | UNIX for Advanced & Expert Users | 1 | 11-11-2002 10:35 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
Delete
Thanks , franklin you method worked, i knew i had to use a while loop and getline in there just didnt know the proper order
Hi everyone, im trying to make the following command line shorter by introducing a script that join up all the grep commands ./new1a < numbers.txt | grep -i -v '^a ' | grep -i -v '^the ' | grep -i -v '^or ' | sort -f How would I go about merging all the greps into a scripe and putting all the words that should be excluded into a data file Last edited by weezybaby; 01-31-2008 at 03:44 PM. |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
With awk you can do something like this:
Code:
awk '
FNR==NR{arr[$1]=$1;next}
!arr[$1]{print}
' "datafile.txt" "numbers.txt"
|
|
#3
|
||||
|
||||
|
Code:
# cat numbers.txt hi how are you what are you doing or am i sleeping the zebra ate the lion yes sir a banana fell # cat exclude.file ^a ^the ^or # /usr/xpg4/bin/grep -v -f exclude.file numbers.txt hi how are you what are you doing yes sir |
|
#4
|
|||
|
|||
|
alright ll give it a try
Last edited by weezybaby; 01-31-2008 at 03:33 PM. |
|
#5
|
|||
|
|||
|
The OP deleted his question, for clarity, this was the request:
Quote:
Try this: Code:
./new < numbers.txt | awk '
BEGIN{while(getline < "datafile.txt" > 0 ) {
arr[$1]=$1
}
close("datafile.txt")
}
!arr[$1]{print}
'
Last edited by Franklin52; 02-01-2008 at 12:46 AM. |
|
#6
|
|||
|
|||
|
Thanks I almost got the same thing, just had some syntax issue that you have corrected . Thank you once again
|
|||
| Google The UNIX and Linux Forums |