Computing.Net > Forums > Unix > Unix script help (strip a period)

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Unix script help (strip a period)

Reply to Message Icon

Name: oly_r
Date: October 26, 2007 at 07:25:53 Pacific
OS: solaris
CPU/Ram: big and lots
Product: sun
Comment:

I am trying to pull data out of a file to execute a series of repetitive commands. One of the fields is a {hex number}.{hex number} pattern. I need the first part of that structure to pass into the command. The file structure is like this:

A 2007/10/20 09:50:00 li text ef6da.1 name 8888.1 99999 path
A 2007/10/20 09:55:00 li text fa57.2a4b8 name 7777.1 99998 path

What i need to do is output a command line for each entry like:

request -p ef6da -m li -v 99999 path
request -p fa57 -m li -v 99998 path

What I am having problems with is splitting the first part of the 6th field, I need the portion prior to the period and not the part after. My attempt has stymied at:

cat filename | awk '{printf "request -p %s -m li -v %s path", $6, $9}' > outfile

I have been trying to modify the field within this format and can't get it to work. MY BRAIN IS FRIED

ANY help would be appreciated. Running on solaris 9 so I have awk, sed, & perl available.



Sponsored Link
Ads by Google

Response Number 1
Name: lankrypt0
Date: October 26, 2007 at 08:09:31 Pacific
Reply:

Hmm, try this:
cat filename | awk '{printf "request -p %s -m li -v %s path\n", $6, $9}'|sed -e "s/\..* -m/ -m/g"

Im basically just using sed to strip off the .XXXX


0

Response Number 2
Name: oly_r
Date: October 26, 2007 at 12:00:49 Pacific
Reply:

That worked perfectly thanks (i missed a space before the second -m at first). I really appreciate your help.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: Unix script help (strip a period)

Unix Script Help www.computing.net/answers/unix/unix-script-help/7992.html

basic unix scripting help www.computing.net/answers/unix/basic-unix-scripting-help/7686.html

Script Help www.computing.net/answers/unix/script-help/5728.html