Copy the linux: Specifies the number of copies of document / file content copy number of the specified line

1, the first N lines of data to copy the file A is file B

:( entered directly at the command line to copy the front line of data.txt to 100,000 in sample.txt)

head -n 100000 data.txt > sample.txt

 

2. Copy the folder A to the N files in folder B

View the number of files folder:

ls -l |grep "^-"|wc -l

Copy the first 100 files to a folder called temp:

ls |head -n 100|xargs -i cp {} /tmp

After you copy the 100 files to a folder called temp:

ls |tail -n 100|xargs -i cp {} /tmp

 

Example:

Guess you like

Origin blog.csdn.net/weixin_41770169/article/details/93171102
Recommended