Computing.Net > Forums > Programming > Bash script text file parsing

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.

Bash script text file parsing

Reply to Message Icon

Name: dchmoo
Date: February 16, 2009 at 15:05:40 Pacific
OS: Linux redhat
Subcategory: Batch
Comment:

Trying to create a process for work to make things simple.

> /tmp/clients.txt
> /tmp/scpcom.txt
serverip=`hostname -i | cut -f1-3 -d'.'`
findsmb | grep $serverip | grep CLIENT | cut -f1 -d' ' | cut -f4 -d'.' > /tmp/clients.txt
for client in `cat /tmp/clients.txt` ; do
echo "$serverip.$client $client" >> /tmp/scpcom.txt
done

for clients in `cat /tmp/scpcom.txt` ;
do echo $clients < ------------
done

My problem is the above command, the text file echo's out like this;


xx.xx.7.13 13
1x.xx.7.14 14
1x.xx.7.15 15
1x.xx.7.16 16
1x.xx.7.80 80
1x.xx.7.81 81

i then want to parse this line to an expect script as 2 variables. so for example

echo $clientip $clientnum
hoping it will output 1x.xx.7.81 81

Can somebody help with this please?



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 Programming Forum Home


Sponsored links

Ads by Google


Results for: Bash script text file parsing

Text File Parsing www.computing.net/answers/programming/text-file-parsing/14194.html

bash script doesnt give same output www.computing.net/answers/programming/bash-script-doesnt-give-same-output/7155.html

Need Help with Bash script www.computing.net/answers/programming/need-help-with-bash-script/16687.html