Results 1 to 10 of 24
This is my script but i wonder why it display error like..
head: unrecognized option `-:'
Try `head --help' for more information.
sed: -e expression #1, char 14: unknown option ...
- 11-14-2007 #1Just Joined!
- Join Date
- Jul 2007
- Posts
- 59
Need help in grep, head and tail
This is my script but i wonder why it display error like..
head: unrecognized option `-:'
Try `head --help' for more information.
sed: -e expression #1, char 14: unknown option to `s'
tail: invalid option -- 1
Try `tail --help' for more information.
Wonder anyone can solve this?
The script i got here is,
#!/bin/bash
#code.h
curl --proxy proxy.tp.edu.sg:80 "www.channelnewsasia.com/singapore/index.htm " > 1.txt :
grepheader=$header:
lines1=${2:-3}:
lines2=${2:-1}:
sub=$'s/<[^<>]*>//g':
cat 1.txt | grep $grepheader | head -$lines1 | sed $sub | tail -$lines2 > data.txt:
exit
- 11-14-2007 #2
What is that colon (:) doing at the end of most of the lines? Remove all of them that are at the ends of lines. But don't remove the colons that are not at the ends of lines.
Hope this helps.--
Bill
Old age and treachery will overcome youth and skill.
- 11-15-2007 #3Linux Engineer
- Join Date
- Feb 2005
- Posts
- 1,044
What wje_lf said (your variable is ending up with a trailing colon, which isn't numeric).
Do you really only want to strip the tags off the last line?
And please don't cat a file into grep - tell grep the name of the file, or redirect it to grep's stdin! Don't be a process hog!
- 11-19-2007 #4Just Joined!
- Join Date
- Jul 2007
- Posts
- 59
i have follow the code you told me to...but it still display results like...
Try `head --help' for more information.
tail: invalid option -- 1
Try `tail --help' for more information.
sed: -e expression #1, char 14: unknown option to `s'
- 11-19-2007 #5Just Joined!
- Join Date
- Jul 2007
- Posts
- 59
- 11-19-2007 #6Code:
cat 1.txt | grep $grepheader
What do you mean by - tell grep the name of the fileCode:grep $grepheader 1.txt
redirect it to grep's stdin! ???Code:grep $grepheader < 1.txt
--
Bill
Old age and treachery will overcome youth and skill.
- 11-20-2007 #7Just Joined!
- Join Date
- Jul 2007
- Posts
- 59
But no matter hw i try , i still cannot get the result i want ...'
i try using the method grep $grepheader < 1.txt.. but still cannot work...
can any1 help me ??
This is what i get after i type in mty file name "./myscript ", but it display nth on my data.txt, just a plain txt only...
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 43044 0 43044 0 0 8838 0 --:--:-- 0:00:04 --:--:-- 10943
100 286 100 286 0 0 10409 0 --:--:-- --:--:-- --:--:-- 10409
Usage: grep [OPTION]... PATTERN [FILE]...
Try `grep --help' for more information.
- 11-20-2007 #8Regards,
who |grep -i blonde |
date; cd~; unzip; touch;
strip; finger; mount; gasp;
yes; uptime; umount;
sleep

Newbie clicks
http://www.linuxforums.org/forum/lin...ead-first.html
- 11-21-2007 #9
I'm guessing that $header, and therefore $grepheader, is empty. This would cause your script to execute the following grep command:
just by itself. Not much there, is there?Code:grep
Want to see whether the header is empty? Just before the offending line in your script, insert these lines:
Code:echo \$header is this: \"$header\" echo \$grepheader is this: \"$grepheader\"
--
Bill
Old age and treachery will overcome youth and skill.
- 11-21-2007 #10Just Joined!
- Join Date
- Jul 2007
- Posts
- 59


Reply With Quote
