array - passing values to sed command
i grep this file and had to delete some of the results with sed - it worked fine
casper@kops11>egrep "cancel|modify|submit" evntlog.89655.Fri | sed -e '/Confirm/d' -e '/Third/d' -e '/find/d' -e '/Local/d' -e '/Auto/d' -e '/GEcp/d' -e '/BookConnectSServer/d' -e '/ExecReport/d' just for investigation sake - i piped the grep results into a different file and then i tried to create a simple array loop that would sed out the line one by one out of the new file - is there a way to pass values to sed? casper@kops11> vi simplearray casper@kops11> more simplearray #!/bin/sh names=( Confirm Third find Local Auto GEcp BookConnectSServer ExecReport ) $(names[@]) for name in $(names[@]) do sed '/"$name"/d' evntlog2.89655.Fri done casper@kops11> chmod +x simplearray casper@kops11> simplearray simplearray: line 4: names[@]: command not found simplearray: line 9: names[@]: command not found |
Quote:
Either leave out the $( ) part or use $( echo names[@] ). Cheers Zhjim |
Or, do it in Perl:
IgnoreKeywords.pl: Code:
#!/usr/bin/perl -w Code:
$ < evntlog.89655.Fri IgnoreKeywords.pl |
Quote:
Code:
for name in "${names[@]}" Code:
for name in $(<file) Code:
while read name; do Code:
# if you're going to read standard input |
All times are GMT -5. The time now is 10:32 PM. |