- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: bash scripting tricks
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
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-22-2004 04:38 AM
04-22-2004 04:38 AM
I recently discovered that in bash, you can create a statement like:
bash# mkdir /mydir/{0,1,2,3}
in order to save typing.
I have a need to create and mount a large number of directories for testing purposes. So, I'd like to do something like:
bash# mkdir /mydir/{0,1,2,3}
bash# mount server:/vol/vol1/{0,1,2,3} /mydir/{0,1,2,3}
The directories I need to mount have numbers for names: 00 through 49. Questions:
1) Will that trick work with mount the same way it does with mkdir? I suspect it will, since it's a function of the shell.
2) Will it work using 00, 01, 02, etc? That is, with a leading zero on the single-digit integers.
3) Is there a way to use a range rather than an explicit numbering scheme--that is, mkdir /mydir/{00-49}, rather than having to type out each of the numbers? Us lazy sysadmins don't like to type, ya know :-)
While I can test on and even feasibly crash and reboot the system on which I'm working, I don't have that luxury with the filesystems I need to mount. So I'd rather go into it forearmed instead of just trying it out and hoping for the best...
Thanks for any help!
Jason
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-22-2004 04:47 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-22-2004 05:00 AM
04-22-2004 05:00 AM
Re: bash scripting tricks
(no points for this please)
-Hazem
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-22-2004 05:01 AM
04-22-2004 05:01 AM
Re: bash scripting tricks
I'd still like an answer to the questions, but since you cut right through the BS and solved the -problem-... :-)
Jason
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-22-2004 05:11 AM
04-22-2004 05:11 AM
Re: bash scripting tricks
i=00
for file in /mydir/*
do
mount server:/vol/vol1/$i /mydir/$i
i=$i+1
if [ $i -lt 10 ]
then
i=0$i
fi
done
(again, no points please since that was part of your original questions)
-Hazem
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-22-2004 05:13 AM
04-22-2004 05:13 AM
Re: bash scripting tricks
i=00
for file in /mydir/*
do
mount server:/vol/vol1/$i /mydir/$i
((i=$i+1))
if [ $i -lt 10 ]
then
i=0$i
fi
done
(again, you know the drill, no points please. Sorry about that, I'm getting hungry and I think I'll go to lunch. Maybe that will fix my brain:))
-Hazem
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-22-2004 05:16 AM
04-22-2004 05:16 AM
Re: bash scripting tricks
Of course, now we're getting away from the 'lazy sysadmin don't wanna type' reason for the original question... ;-)
Jason
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-22-2004 05:38 AM
04-22-2004 05:38 AM
Re: bash scripting tricks
Brace expansion does not appear to work for the mount command. Issuing the command:
bash# mount server:/vol/vol1/{00,01,02} /mydir/{00,01,02}
returns a usage statement.
Still trying to figure out if ranges work with mkdir; so far, they don't.
Perhaps a script combining the two solutions might be the one to work. Ah, well.
Jason