- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: remove certain characters from file name
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
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-18-2005 09:50 AM
08-18-2005 09:50 AM
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-18-2005 09:53 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-18-2005 09:53 AM
08-18-2005 09:53 AM
Re: remove certain characters from file name
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-18-2005 09:54 AM
08-18-2005 09:54 AM
Re: remove certain characters from file name
for file in `ls -1 *-*`
do
newname=`echo $file | sed -e "1,1s/-//g"`
mv $file $newname
done
is better as the first version will complain for the files without dashes in their names, although it will do the job as well.
UNIX because I majored in cryptology...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-18-2005 09:56 AM
08-18-2005 09:56 AM
Re: remove certain characters from file name
for file in `ls -1 *-*`
do
newname=`echo $file | sed -e "1,1s/-//"`
mv $file $newname
done
UNIX because I majored in cryptology...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-18-2005 10:56 AM
08-18-2005 10:56 AM
Re: remove certain characters from file name
# ls *-* | awk -F"-" '{x=$0;sub("-","",$0);system("mv "x" "$0)}'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-18-2005 11:09 AM
08-18-2005 11:09 AM
Re: remove certain characters from file name
# ls *-* | awk -F"-" '{x=$0;gsub("-","");system("mv "x" "$0)}'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-18-2005 05:16 PM
08-18-2005 05:16 PM
Re: remove certain characters from file name
cd
for file in `find . -type f`
do
mv $file $(echo $file | tr -d '-')
done
hth.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2005 03:01 AM
08-19-2005 03:01 AM
Re: remove certain characters from file name
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2005 04:11 AM
08-19-2005 04:11 AM
Re: remove certain characters from file name
Make sure you change it back or only set for your session.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2005 04:12 AM
08-19-2005 04:12 AM
Re: remove certain characters from file name
Worth a try.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2005 04:21 AM
08-19-2005 04:21 AM
Re: remove certain characters from file name
for file in "`ls -1 *-*`"
do
newname=`echo "$file" | sed -e "1,1s/-//g"`
mv "$file" "$newname"
done
regards,
John K.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2005 04:26 AM
08-19-2005 04:26 AM
Re: remove certain characters from file name
ls -1 *-* | while read file
do
newname=`echo "$file" | sed -e "1,1s/-//g"`
mv "$file" "$newname"
done
to remove the first occurance of dash
ls -1 *-* | while read file
do
newname=`echo "$file" | sed -e "1,1s/-//"`
mv "$file" "$newname"
done
UNIX because I majored in cryptology...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2005 04:30 AM
08-19-2005 04:30 AM
Re: remove certain characters from file name
IFS="|"
for i in *; do mv $i ${i/-/}; done
unset IFS
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2005 04:58 AM
08-19-2005 04:58 AM
Re: remove certain characters from file name
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2005 06:12 AM
08-22-2005 06:12 AM
Re: remove certain characters from file name
# ls *-*\ * | awk '{x=$0;gsub(" ","\ ");gsub("-","");gsub(" ","\ ",x);system("mv "x" "$0)}'
awk construct below to remove the first "dash" from a filename that has spaces. Again, this won't remove spaces from a filename, only the first dash:
# ls *-*\ * | awk '{x=$0;gsub(" ","\ ");sub("-","");gsub(" ","\ ",x);system("mv "x" "$0)}'
cheers!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2005 08:32 AM
08-23-2005 08:32 AM