- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- need help with shell scripting 101 class
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
04-05-2005 07:09 AM
04-05-2005 07:09 AM
I am a novice at HP-UX shell scripting. I need help with the syntax of the following.
File A, contains "Buggers".
I want file B with the results of "Huggers Buggers". How would I write a script to concatenate "Huggers " with "Buggers"?
Thanks,
Randy
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2005 07:17 AM
04-05-2005 07:17 AM
Re: need help with shell scripting 101 class
First lesson:
review your questions from the audience perspective. In doing so, you may actually solve the problem.
In this case... where is 'Huggers' coming from? File C? Every other lines in file A?
You might not needs a scripts... the 'paste' command may well do just what you need.
Cheers,
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2005 07:19 AM
04-05-2005 07:19 AM
Re: need help with shell scripting 101 class
cat Huggers Buggers > HuggersBuggers
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2005 07:29 AM
04-05-2005 07:29 AM
Re: need help with shell scripting 101 class
I want to 'hardcode' "Huggers " before whatever value is in file A, so that "Huggers " always preceeds the contents of File A and is written to File B.
Thanks,
Randy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2005 07:35 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2005 07:41 AM
04-05-2005 07:41 AM
Re: need help with shell scripting 101 class
OFILE="FileB"
echo "Huggers \c" > ${OFILE}
cat FileA >> ${OFILE}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2005 07:41 AM
04-05-2005 07:41 AM
Re: need help with shell scripting 101 class
while read -r line
echo "Huggers $line"
done < FileA > FileB
Solution 2)
cat FileA | sed 's/^/Huggers //' > FileB
- Biswajit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2005 07:42 AM
04-05-2005 07:42 AM
Re: need help with shell scripting 101 class
cat filea | while read line
do
var1=$line
echo "Huggers $line"
done
If buggers is field 3 in file a,
lets say filea has the following text
bob has buggers the size of idaho
sally has BugGers that are smaller
Then you want to pick the third word out of file a
cat filea | while read line
do
word=`awk '{print $3}' $line`
echo "Huggers $line"
done
would output
Huggers buggers
Huggers BugGers
Don't forget the shebang line is the first line of your script, and specifies the shell
she - bang #! - get it?
(The exclamation point is the BANG, the pound sign is the comment shhhh)
good luck
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2005 07:47 AM
04-05-2005 07:47 AM
Re: need help with shell scripting 101 class
Ah! Clear:
# cat > a
aap
noot
mies
# perl -ne 'print "Huggers $_"' a > b
# cat b
Huggers aap
Huggers noot
Huggers mies
or
# awk '{print "Huggers " $0}' a
Huggers aap
Huggers noot
Huggers mies
Cheers,
Hien.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2005 08:20 AM
04-05-2005 08:20 AM
Re: need help with shell scripting 101 class
It seems that I need to take a class in scripting and / or the command language.
Thanks,
Huggers Buggers