shell - How to copy files with a particular extension from one directory to another in linux -


i newbie in linux. have write shell script accepts user input ("file extension" , "destination") , copy files 1 directory destination directory.

how that?

try this:

myscript.sh

#/bin/sh ext=${1} dst=${2} cp *.$ext "$dst" 

ex:

$ myscript.sh cpp /home/user/

copies files .cpp extension in current directory /home/user directory


Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -