- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- chown on filenames with spaces in them
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
07-13-2005 06:01 AM
07-13-2005 06:01 AM
cat filenames.txt | while read line
do
chown newname:newgroup $line
done
and it is parsing the spaces as separate lines and all I get is a bunch of "file not found" errors. Does anyone have a workaround for this situation?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-13-2005 06:10 AM
07-13-2005 06:10 AM
Re: chown on filenames with spaces in them
IFS=""
So that spaces don't effect the "read" statement.
Or you could use xargs-
cat filenames.txt | xargs chown newname:newgroup
HTH
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-13-2005 06:14 AM
07-13-2005 06:14 AM
Re: chown on filenames with spaces in them
HTH
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-13-2005 06:18 AM
07-13-2005 06:18 AM
Re: chown on filenames with spaces in them
No such file or directory
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-13-2005 06:23 AM
07-13-2005 06:23 AM
Solutioncat filenames.txt | while read line
do
chown newname:newgroup "${line}"
done
Whitespaces are perfectly legal (though discouraged) characters in pathnames. That is why disciplined shell programmers always quote their variables.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-13-2005 06:23 AM
07-13-2005 06:23 AM
Re: chown on filenames with spaces in them
i.e.
ls t?t
results in
tet
tst
ttt
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-13-2005 06:26 AM
07-13-2005 06:26 AM
Re: chown on filenames with spaces in them
cat filenames.txt | sed "s/\ /\\ /g" > newfilenames.txt
(what the above *should* do is put a backslash in front of each space found in the filenames file - but you should check it out first as I've not done that).
Then, your script from your original posting could work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-13-2005 06:39 AM
07-13-2005 06:39 AM