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 directory
  • break means break loop after first iteration, stop moving files after finding first one

Comments

Popular posts from this blog

download - Firefox cannot save files (most of the time), how to solve? - Super User

windows - "-2146893807 NTE_NOT_FOUND" when repair certificate store - Super User

sql server - "Configuration file does not exist", Event ID 274 - Super User