- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Help me the shell script...
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
05-13-2003 04:02 AM
05-13-2003 04:02 AM
Help me the shell script...
2210
2234
3560
I want to write my own shell script "test.sh" which translate the number to the program using the command such as :
sh test.sh 3560
This script is used to locate the rows of the number.
So anybody can give me some suggestions to write the script, thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-13-2003 04:05 AM
05-13-2003 04:05 AM
Re: Help me the shell script...
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-13-2003 04:07 AM
05-13-2003 04:07 AM
Re: Help me the shell script...
loop to go line by line through file:
--
for i in $(cat /path/to/number)
do
#perform action
done
--
look for occurance of input arg number 1 in file:
--
grep $1 /path/to/number
echo $?
--
Later,
Bill
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-13-2003 04:10 AM
05-13-2003 04:10 AM
Re: Help me the shell script...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-13-2003 04:22 AM
05-13-2003 04:22 AM
Re: Help me the shell script...
As mentioned before try using the grep command.
grep 2210 /path/filename
Regards,
DR
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-13-2003 04:34 AM
05-13-2003 04:34 AM
Re: Help me the shell script...
#! /usr/bin/ksh
echo "enter the number you wish to look for"
read numb
cat number |
while read line
do
linumber=1
if [ $line = $numb ]
then
echo $linumber $numb
((linumber=$linumber+1))
elsif
((linumber=$linumber+1))
if
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-13-2003 04:35 AM
05-13-2003 04:35 AM
Re: Help me the shell script...
#! /usr/bin/ksh
echo "enter the number you wish to look for"
read numb
cat number |
while read line
do
linumber=1
if [ $line = $numb ]
then
echo $linumber $numb
((linumber=$linumber+1))
elsif
((linumber=$linumber+1))
fi
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-13-2003 04:36 AM
05-13-2003 04:36 AM
Re: Help me the shell script...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-13-2003 05:13 AM
05-13-2003 05:13 AM
Re: Help me the shell script...
I think the -n option to grep is what you're after; it'll print the line number of any lines found.
Check the man page for grep(1) for more info. In your script you'll want to use some error checking to cope with times when the number doesn't exist in the file.
Please don't forget to assign points to people that have helped you; it helps others determine which answers are good; and helps reward people for their time and effort helping you.
regards,
Darren.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-13-2003 06:01 AM
05-13-2003 06:01 AM
Re: Help me the shell script...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-13-2003 06:16 AM
05-13-2003 06:16 AM
Re: Help me the shell script...
regards,
Darren.