- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: create directory name (with blank spaces) usin...
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
06-04-2007 04:52 AM
06-04-2007 04:52 AM
I am using the find command to create files from both servers and then the diff command to stripe the directories that must be created and deleted based on the DR server based onthe production environment. I am also using the sed command to add double quotes (") to the begining and end of each line of the file and an if statement is used to read the lines and execute the mkdir command for each line.
The problem we are experiencing is that the system is not interpreting the double quotes and multiple directories are getting created. We also tried using double quotes within the FOR I statement (mkdir "$i")as well as backslashes before the blank space (file\ name)with the same results.
Thank you in advance for any help and/or suggestion.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-04-2007 05:06 AM
06-04-2007 05:06 AM
Re: create directory name (with blank spaces) using a script
Linux example with special chars
Quantum\ Leap\ -\ Season\ 3\ -\ Dvdrip/Quantum\ Leap\ -\ \[3x05\]\ -\ The\ Boogieman\ -\ \(DVDRip\)\ -\ \[Medieval\].avi
Double quote the directory name including spaces.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-04-2007 05:07 AM
06-04-2007 05:07 AM
Re: create directory name (with blank spaces) using a script
td176> mkdir "$x"
td176> ls -l
total 8
drwxrwxrwx 2 antinode 513 4096 Jun 4 13:02 name with spaces
td176> cat md.sh
#!/bin/sh
x='name with spaces in script'
mkdir "$x"
td176> ./md.sh
td176> ls -l
total 24
-rwxrwxrwx 1 antinode 513 52 Jun 4 13:06 md.sh
drwxrwxrwx 2 antinode 513 4096 Jun 4 13:02 name with spaces
drwxrwxrwx 2 antinode 513 4096 Jun 4 13:06 name with spaces in script
It might help if you showed a simple example
of what you're doing. Vague descriptions are
not as good.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-04-2007 05:11 AM
06-04-2007 05:11 AM
Re: create directory name (with blank spaces) using a script
for i in $somevar
do
mkdir $i
done
the i will be the first word "file" the first time thru, "name" the second in this case.
as snippet of the script, and its input would be helpful
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-04-2007 05:15 AM
06-04-2007 05:15 AM
Re: create directory name (with blank spaces) using a script
~thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-04-2007 05:15 AM
06-04-2007 05:15 AM
Re: create directory name (with blank spaces) using a script
A="Clay Dir"
mkdir "${A}"
The key is to double quote everywhere.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-04-2007 05:16 AM
06-04-2007 05:16 AM
Re: create directory name (with blank spaces) using a script
However, going along with your script attempt, it would be a little easier to troubleshoot your script if you showed the actual code you're trying to use. However, based on your description and the mention of a FOR loop, I'll guess you're doing something like:
for I in $(find /dir -type d)
do
mkdir "${I}"
done
Your problem would be that the find command is going to generate a list of directories and the FOR statement is going to take all those spaces in the directory names as separators for unique values to use for I. No matter how you quote or escape within the loop, the results will always be the same.
One option offhand would be dump the find output to a file and use the file as input to a while loop:
find /dir -type d > mkdir.tmp
while read I
do
mkdir "${I}"
done < mkdir.tmp
Jeff Traigle
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-04-2007 05:46 AM
06-04-2007 05:46 AM
Re: create directory name (with blank spaces) using a script
Rsync and rdist are not going to be used because there are close to 4,000 files and we won't need those files there. The application will only need directory structure.
I will be replying with both file outputs shortly.
thank you for your help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-04-2007 05:47 AM
06-04-2007 05:47 AM
Re: create directory name (with blank spaces) using a script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-04-2007 05:48 AM
06-04-2007 05:48 AM
Re: create directory name (with blank spaces) using a script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-04-2007 05:53 AM
06-04-2007 05:53 AM
Re: create directory name (with blank spaces) using a script
thx,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-04-2007 06:08 AM
06-04-2007 06:08 AM
Re: create directory name (with blank spaces) using a script
Jeff Traigle
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-04-2007 06:40 AM
06-04-2007 06:40 AM
Re: create directory name (with blank spaces) using a script
#!/usr/bin/sh
typeset INFILE="/your/file/listing/the directories"
typeset DIRNAME=""
cat ${INFILE} | while read DIRNAME
do
mkdir "${DIRNAME}"
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-04-2007 06:42 AM
06-04-2007 06:42 AM
Solution#!/usr/bin/sh
typeset INFILE="/your/file/listing/the directories"
typeset DIRNAME=""
cat "${INFILE}" | while read DIRNAME
do
mkdir "${DIRNAME}"
done
#NOTE that quotes are need even in the cat "${INFILE}" because in my example the file name contains whitespace
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-04-2007 07:09 AM
06-04-2007 07:09 AM
Re: create directory name (with blank spaces) using a script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-04-2007 07:10 AM
06-04-2007 07:10 AM