Operating System - HP-UX
1825782 Members
2134 Online
109687 Solutions
New Discussion

Re: script help-cut and append text

 
SOLVED
Go to solution
SM_3
Super Advisor

script help-cut and append text

I have a file with two columns (1st column fqdn and 2nd column IP address) of text separated by tabs.
I want to cut the second column, IP address’s.
And then append some text ( a string).

Can you suggest how I can start such a script?

Thanks.
3 REPLIES 3
Simon Hargrave
Honored Contributor
Solution

Re: script help-cut and append text

You want to append a static string to each line, or different text to each?

awk '{print $2" some text"}' myfile
Steve Steel
Honored Contributor

Re: script help-cut and append text

Hi

Simple way to play with fields

cat file|while read a b
> do
> echo $a "cccccccccc" $b
> done


For scripting see
http://www.shelldorado.com/


Steve Steel
If you want truly to understand something, try to change it. (Kurt Lewin)
Franky_1
Respected Contributor

Re: script help-cut and append text

Hi SM,

you can use for example the following script

cat |while read line
> do
> echo "`echo $line|awk '{print $2}'` " >> /tmp/
> done

This would add the IP ($2) and the new string (your_text) into the new created file

Regards

Franky
Don't worry be happy