Shell script to display the number of files which are copying from one directory to another

Kirubakraran :

I want to display the number of files which are copied from one directory to other while doing "CP"command. what could be the command to add to it.

Dominique :

According to cp man-pages, there is the -v parameter, which shows what is being done. This can be processed as in following simple example:

Normal usage of cp -v:

Prompt$ cp -v .bash_history /dev/null
'.bash_history' -> '/dev/null'

Now, with some processing (counting):

Prompt$ cp -v .bash_history /dev/null | wc -l
1

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=174546&siteId=1