![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Replace NULL with space | pukars4u | UNIX for Dummies Questions & Answers | 1 | 06-22-2008 06:15 AM |
| replace space with new line | dakid | Shell Programming and Scripting | 2 | 06-03-2008 09:47 PM |
| How can i replace a character with blank space? | rollthecoin | AIX | 8 | 04-22-2008 09:55 AM |
| Replace , (comma) with space | mbarberis | Shell Programming and Scripting | 6 | 03-29-2005 11:35 AM |
| replace tab with space | avnerht | UNIX Desktop for Dummies Questions & Answers | 1 | 06-13-2002 08:30 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
replace space by _
Hi
I need to know how I change the spaces by _ in folders and filder founded by find ex. find . -name "* *" -exec echo {} \; ./test space ./test space/new file.txt ./test space/new file ./test space/untitled folder ./test space/untitled folder/new fileruben ./Backup/backup/Image for linux Key ./Backup/backup/dings/Backup tool ./Backup/backup/dings/backup reading diff.sh which option should I exec?? thanks |
|
||||
|
Hi
thanks a lot for you script but something strange is happaning. The verbose is correct but nothing happens. It say mv ./new file.txt ./new_file.txt (which is correct) but then it stills the same, even with sudo and the couloured part gives error Any idea? thanks a lot |
|
||||
|
hmm I know why
I have to do mv ./new\ file.txt ./new_file.txt with the \ in the space I think that I can first echo to a file then in the file take the spaces and then use the file to change the space by a _ Do you think it's possible? |
|
||||
|
Try this ...
As i dont have unix machine i havent verified the code in the machine ,
so i suggest you to test code no 1 , if it works then you can proceed with code no 2 #========= #Code No : 1 #========== for i in `find . -name "*" ` do fil_path=`echo $i|tr -s |tr ' ' '_'` echo New fil_path : $fil_path done #========= #Code No : 2 #========== for i in `find . -name "*" ` do fil_path=`echo $i|tr -s |tr ' ' '_'` echo fil_path : $fil_path mv $i $fil_path done I hope it works ........... |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|