Use shell scripts to complete the file copy classification

Using various combinations of shell syntax to achieve C files, java file sorting

(1) themselves create a new folder, the name of self-created
(2) in the folder below to create multiple files c and java files, the name of self-created
(3) write a script to achieve under the current folder to c files copied to the current heads of under test1 directory, if not automatically created in the script, the same way the current folder java copy the file to the directory of the current test2, a key automation.

Experiment Code:
# / bin / bash!

    asd="/home/jim/fenlei/fenlei_c"
    mkdir /home/jim/fenlei/fenlei_c
     mkdir /home/jim/fenlei/fenlei_java
    asd1="/home/jim/fenlei/fenlei_java"
    for zh in *.c
    do
            cp ${zh} ${asd}
    done
    for z in *.java
    do
            cp ${z} ${asd1}
    done

Results:
Here Insert Picture Description
Here Insert Picture Description
In the preparation of documents classified copy the file path to properly set up, we can enter the pwd command to view the native path.

Released three original articles · won praise 0 · Views 31

Guess you like

Origin blog.csdn.net/MZ_journey/article/details/90340681
Recommended