[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: need help with bash command



Bob McGowan a écrit :
for a in `ls`; do DIR=`echo $a | cut -d_ -f2`;  echo  mkdir -p $DIR
/$a; echo rmdir $DIR/$a; echo mv $a $DIR/$a;  done
...
Why do this with a `ls` when a simple * will work?
for a in *; do ...

Hum... Because ! ;-)

In fact, first, I used to do this, because I seldomly use all files in a single directory, but often a pattern in a whole tree with find, second because there was a "ls" in the original problem and third because I did not optimize the command ;-)

I'm sure it is possible to replace the "mkdir -p xxx; rmdir xxx" with something better. For exemple in the problem, it was not needed, a simple "mkdir" would do the job.

Fanfan


Reply to: