Working directory There are Mydoc1.txt,mydoc2.txt...mydoc41.txt, would like to use the SED order of values sorted, and then use cat to merge these files, found not to achieve the desired effect, the merge order is as follows:
Copy Code code as follows:
LS-LF *.txt | Sed-n '/mydoc1/,/mydoc41/p ' | Xargs-i Cat {}> >mynew.txt
found that its command did not achieve the desired effect, and later found that the problem should appear in the SED order, it is still sorted by the number of digits, and there is no intelligent to sort by range, sed values command as follows:
Copy Code code as follows:
LS-LF *.txt | Sed-n '/mydoc1/,/mydoc41/p '
The command displays the results as follows:
Copy Code code as follows:
-rw-r--r--1 root 0 Oct 13:38 mydoc10.txt
-rw-r--r--1 root 0 Oct 13:38 mydoc11.txt
-rw-r--r--1 root 0 Oct 13:38 mydoc12.txt
-rw-r--r--1 root 3 Oct 14:48 mydoc13.txt
-rw-r--r--1 root 0 Oct 13:38 mydoc14.txt
-rw-r--r--1 root 0 Oct 13:38 mydoc15.txt
-rw-r--r--1 root 0 Oct 13:38 mydoc16.txt
-rw-r--r--1 root 0 Oct 13:38 mydoc17.txt
-rw-r--r--1 root 0 Oct 13:38 mydoc18.txt
-rw-r--r--1 root 0 Oct 13:38 mydoc19.txt
-rw-r--r--1 root 0 Oct 13:38 mydoc1.txt
-rw-r--r--1 root 0 Oct 13:38 mydoc20.txt
-rw-r--r--1 root 0 Oct 13:38 mydoc21.txt
-rw-r--r--1 root 0 Oct 13:38 mydoc22.txt
-rw-r--r--1 root 0 Oct 13:38 mydoc23.txt
-rw-r--r--1 root 0 Oct 13:38 mydoc24.txt
-rw-r--r--1 root 0 Oct 13:38 mydoc25.txt
-rw-r--r--1 root 0 Oct 13:38 mydoc26.txt
-rw-r--r--1 root 0 Oct 13:38 mydoc27.txt
-rw-r--r--1 root 0 Oct 13:38 mydoc28.txt
-rw-r--r--1 root 0 Oct 13:38 mydoc29.txt
-rw-r--r--1 root 0 Oct 13:38 mydoc2.txt
-rw-r--r--1 root 0 Oct 13:38 mydoc30.txt
-rw-r--r--1 root 0 Oct 13:38 mydoc31.txt
-rw-r--r--1 root 0 Oct 13:38 mydoc32.txt
-rw-r--r--1 root 0 Oct 13:38 mydoc33.txt
-rw-r--r--1 root 0 Oct 13:38 mydoc34.txt
-rw-r--r--1 root 0 Oct 13:38 mydoc35.txt
-rw-r--r--1 root 0 Oct 13:38 mydoc36.txt
-rw-r--r--1 root 0 Oct 13:38 mydoc37.txt
-rw-r--r--1 root 0 Oct 13:38 mydoc38.txt
-rw-r--r--1 root 0 Oct 13:38 mydoc39.txt
-rw-r--r--1 root 2 Oct 14:48 mydoc3.txt
-rw-r--r--1 root 0 Oct 13:38 mydoc40.txt
-rw-r--r--1 root 6 Oct 14:48 mydoc41.txt
So use the following command to implement the requirements: The command looks like this:
Copy Code code as follows:
For ((i=1;i<=41;i++)) do echo Mydoc$i.txt;done | Xargs-i Cat {} >> Mynew.txt