![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | 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 and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Page feed in Troff | dpmore | UNIX for Dummies Questions & Answers | 2 | 05-18-2008 05:22 AM |
| Three feed plugins for WordPress | iBot | UNIX and Linux RSS News | 0 | 04-07-2008 05:40 AM |
| Firefox feed extensions | iBot | UNIX and Linux RSS News | 0 | 02-25-2008 05:10 AM |
| Needing a line feed for windows app | benefactr | Shell Programming and Scripting | 5 | 11-13-2007 01:39 PM |
| Form Feed... | johnny_woo | UNIX for Dummies Questions & Answers | 5 | 10-31-2003 06:02 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
try this: Code:
egrep -n 'zcat|touch' preou*|\
awk -F: '{print $1}'|\
paste -sd ",\n" -|\
sed 's=\(.*\)=sed -n "\1p" mymail | uudecode='|\
sh
You can run each consequtive piped-command to see what it produces and how the complete pipe does he job. |
|
|||||
|
Thanks for your replies, unilover and Franklin52. I intend to work through both of your suggestions, to learn from them. I am of course aware that there are probably dozens or hundreds of possible solutions to this problem; but I'm also trying to take things one step at a time and figure out what was missing in my attempts. Right now I'm looking at unilover's solution, and I'm a little bit stumped: I've tried the first part of his solution, and this is what I initially got: Code:
grep -n -E "begin|end" /tmp/tmp.mail 11:Received-SPF: pass (google.com: domain of gropers@xxx.xxx designates 192.168.64.20 as permitted sender) client-ip=192.168.64.20; 12:Authentication-Results: mx.google.com; spf=pass (google.com: domain of gropers@xxx.xx designates 192.168.64.20 as permitted sender) smtp.mail=gropers@xxx.xxx 35:begin 666 IMG_1232.jpg 585:end 587:begin 666 IMG_1229.jpg 1152:end 1154:begin 666 IMG_1221.jpg 2010:end 2012:begin 666 IMG_1217.jpg 2936:end 2938:begin 666 IMG_1215.jpg 4032:end 4034:begin 666 IMG_1192.jpg 4536:end 4538:begin 666 IMG_1190.jpg 5225:end 5227:begin 666 IMG_1189.jpg 5642:end 5644:begin 666 IMG_1188.jpg 6278:end 6280:begin 666 IMG_1185.jpg 6889:end 6891:begin 666 IMG_1184.jpg 7731:end 7733:begin 666 IMG_1183.jpg 8235:end 8237:begin 666 IMG_1247.jpg 9132:end 9134:begin 666 IMG_1244.jpg 9824:end 9826:begin 666 IMG_1242.jpg 10611:end 10613:begin 666 IMG_1238.jpg 11295:end 11297:begin 666 IMG_1237.jpg 11891:end 11893:begin 666 IMG_1235.jpg 12323:end 12325:begin 666 IMG_1234.jpg 13215:end 13217:begin 666 IMG_1233.jpg 13765:end Note the output lines 11 and 12, which don't contain "begin" or "end". (Yes, I changed the email addresses and IP addresses, but I did that in /tmp/tmp.mail, in which lines 11 and 12 really don't contain either string.) It also didn't matter whether I used grep -E or egrep, or single or double quotes. At long last, I finally figured out what tripped up grep: It turns out that lines 11 and 12 both contained carriage returns (\r). vi confirmed this by showing the familiar ^M characters. I then did :%s/\r//g in vi and saved the file, after which grep worked as expected, and the lines 11 and 12 were no longer included in its output. So I know what made the error occur. What I don't understand is why this error occurred. Why would extraneous carriage returns cause grep to include these lines? ![]() Many thanks for your help.
|
|
|||||
|
Arrgh!!! Nevermind the aforesaid, I've just figured things out -- turns out I was wrong when I wrote that the lines 11 and 12 don't contain "begin" or "end". Both lines contain the word "sender". The carriage returns were a total red herring. I was wrong when I thought that removing them had fixed things. It turns out that when I tested grep after removing them I had only grepped "begin" and not "begin|end". ![]() So it's probably not a good idea to grep for "end" in this case without throwing away the email headers first. In my initial --only partially successful-- approach this also was unnecessary, because tail lends itself really well to clipping off the upper parts of the file without even looking at them (and uudecode ignores anything boyond the first uuencoded file, so the rest can be left as it). On a more positive note, I've found that Code:
grep -n -E "begin|end" /tmp/tmp.mail | awk -F : '{print $1}' | paste -s -d ",\n" - | sed 's=\(.*\)=sed -n "\1p" /tmp/tmp.mail | uudecode='| sh -
does indeed work -- though it complains: Code:
uudecode: stdin: No `begin' line which is entirely understandable, because the command line Code:
sed -n "11,12p" /tmp/tmp.mail | uudecode that's generated and passed to sh is bogus, and of course line 11 has no "begin" in it. I still don't fully understand the nested sed stuff though. I'll try some more and/or come back with more questions. Also, if someone has a hint to get my initial approach with awk and tail to work, that would be really cool. ![]() But again, many thanks so far.
Last edited by ropers; 04-02-2008 at 09:51 PM.. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|