- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: How to read each line into a variable and do s...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-27-2003 05:12 PM
08-27-2003 05:12 PM
I have file in the format
xxx1 100 120
xxx2 230 250
xxx3 200 300
I want to go through each line of this file and read 3 words into 3 different varaibales uri, start_item and end_item. I need to do this in a loop and I have another script which takes these 3 varaiables and creates another output for each line.
How can I do this within a loop ?
Can some Shell/Awk Guru help me ?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-27-2003 05:20 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-27-2003 05:27 PM
08-27-2003 05:27 PM
Re: How to read each line into a variable and do some operation - Shell Script Question ??
Wouldn't 3 separate read lines be required?
Tim.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-27-2003 05:34 PM
08-27-2003 05:34 PM
Re: How to read each line into a variable and do some operation - Shell Script Question ??
Tim.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-27-2003 06:09 PM
08-27-2003 06:09 PM
Re: How to read each line into a variable and do some operation - Shell Script Question ??
Now that I can read all 3 into variables A, B and C.
I want to concatenate some string to variable A.
e.g.
infile=test.txt
cat $infile | while read A B C
do
filename=$A + ".bif"
echo "$A $B $C $filename
done
Can I do something like that ? It doesn't work ?
How do I concatenate a string ".bif" to $A for each line while I am doing the loop.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-27-2003 06:24 PM
08-27-2003 06:24 PM
Re: How to read each line into a variable and do some operation - Shell Script Question ??
>outfile
infile=test.txt
cat $infile | while read A B C
do
echo $A $B $C $A.bif >>outfile
done
Rob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-27-2003 06:37 PM
08-27-2003 06:37 PM
Re: How to read each line into a variable and do some operation - Shell Script Question ??
infile=test.txt
cat $infile | while read A B C
do
echo $A $B $C >>$A.bif
done
Rob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-27-2003 07:07 PM
08-27-2003 07:07 PM
Re: How to read each line into a variable and do some operation - Shell Script Question ??
This is what I want:
I have a file1 with following content:
xxx1 100 105
xxx2 200 210
xxx3 150 175
For each line of this file, I need to genearte a new file with contenats and file name
in the pattern:
file: xxx1.bif
http://yyy.com/test.cgi?cmd=item-100&group=xxx1
http://yyy.com/test.cgi?cmd=item-101&group=xxx1
..
..
http://yyy.com/test.cgi?cmd=item-105&group=xxx1
file: xxx2.bif
http://yyy.com/test.cgi?cmd=item-200&group=xxx2
http://yyy.com/test.cgi?cmd=item-201&group=xxx2
..
..
http://yyy.com/test.cgi?cmd=item-210&group=xxx2
I am trying following script and it doesn't work:
infile=test.txt
url="http://yyy.com/test.cgi?cmd=item-"
uri="group="
suffix=".bif"
cat $infile | while read name start end
do
filename=`expr $name$suffix`
if [$end -gt $start]
then
while [$end -ge $start]
do
echo $url$end$uri$name >> $filename
echo "<
end=`expr $end-1`
done
done
Any help is appreciated. The inner loop fails.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-27-2003 07:26 PM
08-27-2003 07:26 PM
Re: How to read each line into a variable and do some operation - Shell Script Question ??
Maybe you could ask the entire question the first time(??).
http://us-support.external.hp.com/estaff/bin/doc.pl/screen=estaffAssistance/distrib_redir=0+1062041015|*?Page=file0002
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-27-2003 07:36 PM
08-27-2003 07:36 PM
Re: How to read each line into a variable and do some operation - Shell Script Question ??
sorry - bad link
http://us-support.external.hp.com/estaff/bin/doc.pl/screen=estaffAssistance?Page=file0002#forassign
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-27-2003 09:04 PM
08-27-2003 09:04 PM
Re: How to read each line into a variable and do some operation - Shell Script Question ??
Shell Scripting Help .. Please Help