- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- simple 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
02-08-2007 10:15 AM
02-08-2007 10:15 AM
I want to create such a script script.sh that for every two different numbers X and Y when X>Y it can do
X
X+1
X+2
...
Y
up to X=Y
e.g.
./script 5 9
it should returns
5
6
7
8
9
That should happen for every 2 different numbers.
Thanks
Andy
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2007 10:27 AM
02-08-2007 10:27 AM
Re: simple script
# awk 'END {for (i=X; i<=Y; i++) {print i}}' X=5 Y=9 /dev/null
...specify any value of 'X' and 'Y' you want.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2007 12:33 PM
02-08-2007 12:33 PM
Re: simple script
perl -le 'print for (shift..shift)' 5 9
-l : print a linefeed after each print
-e : command text coming
print : prints default variable $_
for (x..y) : load default variable $_ with values from x through y in a loop
shift : grab next command line argument
Enjoy,
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2007 02:26 PM
02-08-2007 02:26 PM
Re: simple script
#!/usr/bin/sh
if [[ ${#} -lt 2 ]]
then
echo "Usage: ${0} lo hi" >&2
exit 255
fi
typeset -i LO=${1}
typeset -i HI=${2}
shift 2
while [[ ${LO} -le ${HI} ]]
do
echo "${LO}"
((LO += 1))
done
exit 0
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2007 04:25 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2007 08:51 PM
02-11-2007 08:51 PM
Re: simple script
use the function range:
function range
{
#######################################################
# Shows all numbers from start_range to end_range
[[ $# -lt 1 || $# -gt 2 ]] && echo "Usage: range start_range and_range" && return
lo=$1
hi=$2
while [ $lo -le $hi ]
do
echo "$lo \c"
lo=$(expr $lo + 1)
done
echo
unset lo hi
}
range 1 5 9
HTH,
Art
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2007 04:17 AM
02-23-2007 04:17 AM