- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: how to parse a list
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
Discussions
Discussions
Forums
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
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-25-2004 06:50 AM
тАО08-25-2004 06:50 AM
I am reading a path A/B/C/D/.... froma file .
and creating a directory srtucture starting with subdirectory C under my home (~me/C/D/...)
In this path, the number of subdirectories could vary . Is there any way I can check how many subdirectories are there under and create those direcotroes dynamically thru the script?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-25-2004 06:54 AM
тАО08-25-2004 06:54 AM
Re: how to parse a list
I'm not exactly sure if this is what you're asking, but you could always use the -p option of mkdir and it will create as many directories and subdirectories as you specify in a single command.
For example:
# ls /A
/A not found
# mkdir -p /A/B/C/D/E/F/G
# ll /A/B/C/D/E/F
total 0
drwxrwxrwx 2 root users 96 Aug 25 11:02 G
So with one command I created an entire directory hierarchy, regardless of the number of subdirectories.
Again, not sure if this is what you were looking for, but thought it might help.
Regards,
Dave
[Any personal opinions expressed are mine, and not official statements on behalf of Hewlett Packard Enterprise]
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-25-2004 06:59 AM
тАО08-25-2004 06:59 AM
Re: how to parse a list
I am reading a path from a file in the file I have A/B/C/D in the file. from the file i have to read and create directories in my home.. hope i m not confusing
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-25-2004 07:00 AM
тАО08-25-2004 07:00 AM
Solutionmkdir -p ~me/C/D/P/Z
But if you like to know the nummer of directories that need to be created reading from the file you can use awk
echo "A/B/C/D" | awk -F / '{print NF}'
HTH (if I understand you correct?),
Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-25-2004 07:13 AM
тАО08-25-2004 07:13 AM
Re: how to parse a list
$ x="A/B/C/D"
$ y=${x#A/B/}
$ echo $y
C/D
$ mkdir -p $y
HTH
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-25-2004 07:45 AM
тАО08-25-2004 07:45 AM
Re: how to parse a list
$ IFS="/" ; b=A/B/C/D ; set -A a $b ; echo ${a[0]} ${#a[*]}
This will print "A" (for ${a[0]}) and "4" (for ${#a[*], number of elements).
HTH
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-25-2004 07:48 AM
тАО08-25-2004 07:48 AM
Re: how to parse a list
Assigning of points wouldn't offend any of us :-)
...