Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

4
  • It is not a requirement at all :), it's just something I learned so far. I find the existing shell scripting tutorial quite awful for newbies. Commented Aug 30, 2016 at 15:15
  • 1
    Here, you're using the split+glob operator on the output of find, but are not tuning it properly. You'd want to set IFS to newline and disable the glob part. There's no reason you'd want to invoke it on $ii Commented Aug 30, 2016 at 15:34
  • @StéphaneChazelas I just learned a number of things reading your answer here, thanks ! I feel it's not worth tuning IFS and the globbing if filenames are "standard", but it's clearly something to be aware of. Commented Aug 30, 2016 at 19:51
  • 1
    @AlexStarbuck Here is the result : mv ./DE_AT/adventure/motovun/300x250/A2_300x250.zip someString_DE_AT_motovun+A2_300x250.zip. I tell awk (option -F/) to split the string using / (by default it splits on blanks). $i refers to the ith field ($0 is the whole string). Since find prefixes its output with the directory where it searches, which we set to ., the first field ($1) is . — therefore $2=DE_DE. Commented Aug 31, 2016 at 13:12