command line - Moving only the first file from any directory to current one - Ask Ubuntu
i have 2 directories called 1
, poscars
, there files in poscars
directory. want move first file poscars
directory 1
directory while in 1
directory.
thanks advice
if want move first file in directory, current working directory, can use for
, because loops on files in ordered way. replace /path/to/
real path poscars
directory, , test first echo
:
for file in /path/to/poscars/* ; echo mv -v -- "$file" . ; break ; done
this find first file in poscars
, simulate moving current working directory. if shows want, re-run command without echo
move file:
for file in /path/to/poscars/* ; mv -v -- "$file" . ; break ; done
mv -v --
move file , report action, not accept further options.
current working directorybreak
means break loop after first iteration, stop moving files after finding first one
Comments
Post a Comment