linux - what is the working of this command ls . | xargs -i -t cp ./{} $1 -


i new bee bash scripting. while studying advanced bash scripting came across command. i'm not understand how command working , use of curly braces. in advance.

your command:

ls . | xargs -i -t cp ./{} $1 

could divided following parts:

  ls .  

list current directory (this list files/directories hidden ones)

| xargs -i -t cp ./{} $1 

basically xargs breaks piped output (ls in case) , provides each element in list input following command (cp in case). -t option show in stderr xargs executing. -i used string replacement. in case since nothing has been provided substitute {} input. $1 name of destination files copied (i guess in case should directory command make sense otherwise copying files same destination).

so example, if have lets directory has files called a, b, c. when run command perform following:

cp ./a $1 cp ./b $1 cp ./c $1 

note:

the -i option deprecated, -i (uppercase i) should used instead


Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -