Bash 2 several words filename
Hello guys. I am making a script which one of the functions hide files.
Code:
#!/bin/bash |
.hidden files
First, you would do better with a case statement instead of if statements. Second, do you mean that when you have spaces in a file name, that your script fails? If so, double quote your expansions, e.g. "$i"
|
i tried double quote before but still dos not work.
|
maybe any suggestions?
|
If file names have spaces in them the for loop will not work as it will break each file into the whitespace separated pieces.
Maybe you could show us how you are calling your script as the format you currently have is a little vague? |
Use find(1).
something like this (not tested): Code:
find . -name "*mask" -exec mv "{};" ."{};" |
Yes, more info please. But to start with, check out these links:
http://mywiki.wooledge.org/Arguments http://mywiki.wooledge.org/WordSplitting http://mywiki.wooledge.org/Quotes http://mywiki.wooledge.org/BashPitfalls See 1, 2, 4, 10 in particular. And perhaps 24 and 37. $(..) is highly recommended over `..` Have a look at the shift built-in command. Arrays might possibly be of use too, depending on your exact requirements. See the BashGuide for more on them and other general scripting advice: http://mywiki.wooledge.org/BashGuide |
i call my script like this
Quote:
|
Well if you are guaranteeing all file names look just like that, I see no issues as script will work without issue.
|
All times are GMT -5. The time now is 05:32 AM. |