2
I have isseued the next command in order to move some directories to the "build_tools" folder however the result was not the one I expected.
ls -l | grep 2014-03 | awk '{if ($8!=build_tools) print $8}' | xargs mkdir build_tools/{} && mv {}/ build_tools/{}/
It moved the folder "build_tools" to one of the folders yielded by awk (zlib) altogether with the rest of directories and then it got stuck with this message:
mkdir: no se puede crear el directorio «zlib»: El archivo ya existe
Can somebody shed some light on what is my mistake?
EDIT 1:
The output of ls -l gives me:
drwxr-xr-x 3 poissonbreaker poissonbreaker 4096 2011-05-02 09:58 antlr3.2
-rw-r--r-- 1 poissonbreaker poissonbreaker 318588 2011-05-17 16:21 AppFramework-1.03.jar
-rw-r--r-- 1 poissonbreaker poissonbreaker 0 2014-03-04 09:53 awk
drwxr-xr-x 4 poissonbreaker poissonbreaker 4096 2013-01-11 23:13 clutter-sharp
-rw-r--r-- 1 poissonbreaker poissonbreaker 429 2014-01-14 09:49 Dependencias
I just want to get the files with the date field ($6) matching 2014-03, that is why I do a simple grep of it as (No file in the directory has as filename this pattern):
ls -l | grep 2014-03
Which yields:
-rw-r--r-- 1 poissonbreaker poissonbreaker 0 2014-03-04 09:53 awk
-rw-r--r-- 1 poissonbreaker poissonbreaker 429 2014-01-14 09:49 Dependencias
Then I get the filename field ($8) of every file through awk to finally be moved to build_tools folder (At this point I know what was my mistake -- the build_tools folder has also been created on this date :S). I will leave this question here though, in case some parts will be useful for anyone.
EDIT 2: I have changed the awk expression to:
awk '{if ($8!=build_tools) print $8}'
for it to make sense.
See my updated answer – slhck – 2014-03-04T12:09:54.193