|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
hi,
I've just written a bourne shell script to be run on Solaris 5.8 to extract URL's containing issues number from some text file (such as URL) and get the current status and resolution of the issue online. The result should display with the 3 words on the same line, 1 single space between each word, such as : 1881 CLOSED FIXED (issue number, status, resolution) So far I have been trying to use echo or printf with different combination but I most of the time get things like: CLOSED FIXED (issue number does show up) or 1881 CLOSED FIXED (not the same line) If anyone could give me a clue, that would be great! thanks! The script is ran like this: script.sh mail.txt (data file) code: #!/bin/sh LIST_OF_URLS=`grep 'http://.*/show_bug.cgi' $1 | tr -d [=\>=][:blank:]| sort | uniq` for URL in $LIST_OF_URLS do PAGE_TEXT=`lynx -dump $URL` THIS_ID=`echo "$URL" | nawk -F 'id=' '{print $2}'` STATUS=`echo "$PAGE_TEXT" | grep ']Status:' | tr -d [:lower:][:digit:][=[=][=]=][=:=] | nawk -F ' ' '{print $2}'` RESOLUTION=`echo "$PAGE_TEXT" | grep ']Resolution:' | nawk -F '\[' '{print $2}' | tr -d [:lower:][:digit:][=[=][=]=][=:=] | nawk -F ' ' '{print $2}'` echo $THIS_ID $STATUS $RESOLUTION done I have attached a sample data file for testing |
|
#2
|
||||
|
||||
|
This script outputs:
10797 CLOSED FIXED 1881 STARTED 787 RESOLVED LATER for me on FreeBSD with the script and data file you provided - is that not correct? I'm wondering if it's perhaps some difference between nawk on the different OS's you're testing on? How about if you used sed instead of awk to get the id: Code:
THIS_ID=`eval echo "$URL" | sed -e 's/.*id=\(.*\)$/\1/'` which should ensure you don't catch any newline chars at the end of the URL (as I say though it works ok for me with freebsd's nawk). Alternatively you could use expr(1) as well I believe, although I'm not sure about the syntax for expr(1).
__________________
FreeBSD Admin Tips Tricks and Scripts |
![]() |
| Viewing: Dev Shed Forums > Operating Systems > UNIX Help > Print 3 variables on same line |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|