nl
stringlengths 13
387
| bash
stringlengths 1
532
|
---|---|
Copy a comlex directory tree from one machine o another while preserving copy permissions and ownership | find . -depth -print | cpio -o -O /target/directory |
copy a files from one folder to all the folder in the /raid which have an extension local_sd_customize. | find /raid -type d -name ".local_sd_customize" -ok cp /raid/04d/MCAD-apps/I_Custom/SD_custom/site_sd_customize/user_filer_project_dirs {} \; |
Copy a file xyz.c to all the directories below the current one whose names begin with "temp" | find . -type d -name "temp*" | xargs -n1 cp xyz.c |
Copy a file xyz.c to all directories or over all files matching the letter 'c' at the end of their names under current directory tree | find . -name "*c" -print0 | xargs -0 -n1 cp xyz.c |
Copy a large sparse file "sparse-1" to "sparse-1-copy" | rsync --sparse sparse-1 sparse-1-copy |
Copy a whole directory tree skipping files residing on other files systems to destination_dir | find ./ -mount -depth -print | cpio -pdm /destination_dir |
Copy all ".php" files in "projects/" directory tree to "copy/" preserving directory hierarchy | find projects/ -name '*.php' -print | cpio -pdm copy/ |
Copy all *.mp3 files under the current directory to /tmp/MusicFiles/ | find . -type f -name "*.mp3" -exec cp {} /tmp/MusicFiles \; |
Copy all .patch files from the current directory tree to patches/ | find -name '*.patch' -print0 | xargs -0 -I {} cp {} patches/ |
Copy all .pdf files in the ./work/ directory tree with size bigger then 2 MB and modified more than 5 days ago to the ./backup/ directory | find ./work/ -type f -name "*.pdf" -mtime +5 -size +2M | xargs -r cp -t ./backup/ |
Copy all .png files from the home directory tree to imagesdir/ | find ~/ -name *.png -exec cp {} imagesdir \; |
Copy all .txt files from the dir/ directory tree along with their parent directories hierarchy | find dir/ -name '*.txt' | xargs cp -a --target-directory=dir_txt/ --parents |
Copy all files and directories in "/home/" to "/newhome" preserving directory hierarchy and modification time | find /home/ -maxdepth 1 -print | sudo cpio -pamVd /newhome |
Copy all files and directories under the current directory into "../new" preserving relative paths | find -print0 | sort -z | cpio -pdv0 ../new |
Copy all files below the current directory whose names contain "FooBar" to directory foo/bar/ in user's home directory. | find -name '*FooBar*' -print0 | xargs -0 cp -t ~/foo/bar |
Copy all files below the current directory whose names contain "FooBar" to directory foo/bar/ in user's home directory. | find . | grep FooBar | xargs -I{} cp {} ~/foo/bar |
Copy all files below the current directory whose names contain "foobar" (case-insensitive) to directory foo/bar/ in user's home directory. | find . -iname "*foobar*" -exec cp "{}" ~/foo/bar \; |
Copy all files ending in ".a" in directory trees matching "folder*" to "/path/to/dest" preserving directory hierarchy | find folder* -name '*.a' -print | cpio -pvd /path/to/dest |
Copy all files from the current directory tree to /path/to/destination/dir preserving their times, permissions, and ownership | find . | cpio -pdumv /path/to/destination/dir |
Copy all files in "/var/spool/mail" to "/home/username/mail" preserving the directory hierarchy and modification times | find /var/spool/mail -type f | cpio -pvdmB /home/username/mail |
Copy all files in the current directory except those containing 'Music' to '/target_directory'. | cp `ls | grep -v Music` /target_directory |
Copy all files in current directory that do not match */exlude-path/* in their paths to /destination/ preserving directory structure | find . -type f -not -path '*/exlude-path/*' -exec cp --parents '{}' '/destination/' \; |
Copy all files in current directory that do not match */not-from-here/* in their names to /dest | find . -type f -not -iname '*/not-from-here/*' -exec cp '{}' '/dest/{}' ';' |
Copy all files in current directory that do not match */not-from-here/* in their paths to /dest | find . -type f -not -path '*/not-from-here/*' -exec cp '{}' '/dest/{}' \; |
Copy all files in the current directory tree matching "textToSearch" to "$destination_path" | find . -type f | xargs grep -l "textToSearch" | cpio -pV $destination_path |
Copies all files like "*FooBar*" under the current directory to the '~/foobar' directory. | find . -name '*FooBar*' -exec cp -t ~/foobar -- {} + |
Copies all files like 'lib*.so' to '~/usr/gtest/lib/' directory. | cp lib*.so ~/usr/gtest/lib |
Copy all files matching "*.sh" in "$from/*" to "root@$host:/home/tmp/" compressing data during transmission | rsync -zvr --include="*.sh" --exclude="*" $from/* root@$host:/home/tmp/ |
Copy all files matching "*failed.ipynb" in the current directory tree to "./fails" preserving the directory hierarchy | find . -name "*failed.ipynb" | cpio -pd ./fails |
Copy all files matching "file_name.extension" to "/path/to/receiving/folder" preserving directory hierarchy | find . -name 'file_name.extension' -print | cpio -pavd /path/to/receiving/folder |
Copy all files named 'script.sh' in directory 'olddir' to directory 'newdir' | find olddir -name script.sh -printf "%p\0" -printf "newdir/%P\0" | xargs -0L2 cp -n |
Copy all files that match 'FooBar' in their paths under current directory tree to the '~/foo/bar' directory | find . | grep "FooBar" | tr \\n \\0 | xargs -0 -I{} cp "{}" ~/foo/bar |
Copy all files unconditionally and directories in directory tree "myfiles" to "target-dir" preserving directory hierarchy and modification time | find myfiles | cpio -pmud target-dir |
Copies all files under the current directory like any-cased '*foobar*' to the '~/foo/bar' directory. | find . -iname "*foobar*" -exec cp "{}" ~/foo/bar \; |
Copies all files under the current folder like "file.ext" with "FooBar" in the path to the root of the current folder, preserving mode, ownership and timestamp attributes. | find . -name "file.ext"| grep "FooBar" | xargs -i cp -p "{}" . |
Copy all files under director 'foo' whose name doesn't contain 'Music' to directory 'bar'. | find foo -type f ! -name '*Music*' -exec cp {} bar \; |
copy all files which do not have execute permission to another folder | cp `find -perm -111 -type f` /usr/local/bin |
Copies all files with "FooBar" in the path under the current directory to the '~/foo/bar' directory. | find . | grep FooBar | xargs -I{} cp {} ~/foo/bar |
Copy all files with '.png' (case insensitive) extension under '/home/mine' directory tree to '/home/mine/pngcoppies/' directory with new names constructed by prepending 'copy' in their names | find /home/mine -iname "*.png" -printf "%P\n " | xargs -I % -n1 cp % /home/mine/pngcoppies/copy% |
Copy all files with '.png' (case insensitive) extension under '/home/mine' directory tree to '/home/mine/pngcoppies/copy.' directory | find /home/mine -iname "*.png" -execdir cp {} /home/mine/pngcoppies/copy{} \; |
Copy all files with name pattern $j.sh (case insensitive) under '/tmp/2' directory tree to $i directory | find "/tmp/2/" -iname "$j.sh" -exec cp {} "$i" \; |
copy all the log files in the current folder which have not been accessed in the last 30*24 hours to the folder old | find . -type f -mtime +30 -name "*.log" -exec cp {} old \; |
copy all the mp3 files from current folder to another folder | find . -name '*.mp3' -exec cp -a {} /path/to/copy/stuff/to \; |
Copy all regular files from the current directory tree to directory `TARGET' | find . -type f -exec cp -t TARGET {} \+ |
copy all the regular/normal files from temp folder which have been modified in the last 30*24 hours to /tmp/backup | find /tmp -type f -mtime -30 -exec cp {} /tmp/backup \; |
copy all the regular files in the current directory to the temporary diectory. | find . -type f -exec cp {} /tmp + |
Copy all regular files whose names end in "~" from the /path directory tree to ~/backups/ | find /path -type f -name '*~' -print0 | xargs -0 -I % cp -a % ~/backups |
Copy an entire file structure, creating empty files in the copy instead of copying the actual files. | find src/ -type d -exec mkdir -p dest/{} \; -o -type f -exec touch dest/{} \; |
Copy and always overwrite all files in "/zzz/zzz" to "/xxx/xxx" | yes | cp -rf /zzz/zzz/* /xxx/xxx |
Copy the current directory tree to "newdirpathname" preserving directory hierarchy | find ./ -depth -print | cpio -pvd newdirpathname |
Copy the current directory tree to '/path/to/destination/dir' preserving permissions, timestamp and ownership | find . | cpio -pdumv /path/to/destination/dir |
Copy directory hierarchy "dir" and all its .txt files to "dir_txt" | find dir/ -name '*.txt' | xargs cp -a --target-directory=dir_txt/ --parents |
Copy the directory hierarchy from "original" to "new" | find original -type d -exec mkdir new/{} \; |
Copy directory hierarchy from the current working directory to "/path/to/backup/" | find . -type d -exec mkdir -p -- /path/to/backup/{} \; |
Copy the directory hierarchy of the current directory to "destdir" | find . -type d | cpio -pdvm destdir |
Copy the directory structure in "src/" to "dest/" with empty files | find src/ -type d -exec mkdir -p dest/{} \; -o -type f -exec touch dest/{} \; |
Copy directory tree preserving UID and GID and leaving user files alone | find . -depth -print | cpio -o -O /target/directory |
Copy the entire "/lib" and "/usr" directory including symlinks from "[email protected]" to "$HOME/raspberrypi/rootfs" and delete files after the transfer | rsync -rl --delete-after --safe-links [email protected]:/{lib,usr} $HOME/raspberrypi/rootfs |
Copy the entire contents of the current directory preserving ownership, permissions, and times | find . | cpio -pdumv /path/to/destination/dir |
copy the entire contents of the current directory to another directory, while preserving the permissions, times, and ownership of every file and sub-directory | find . | cpio -pdumv /path/to/destination/dir |
Copy the entire directory tree under t1 to t2, do not create a containing t1 directory in t2. | cp -R t1/ t2 |
Copy file "exist" from directory "/file/that" to a new file named "file" in "/location/for/new" | cp /file/that/exists /location/for/new/file |
Copies file '/boot/config-`uname -r`' to the '.config', printing info message and prompting before owerwriting files. | cp -vi /boot/config-`uname -r` .config |
Copies file 'file.dat' to each top-level directory in the current directory. | ls | xargs -n 1 cp -i file.dat |
Copies file 'file.txt' to each top-level directory in the current directory. | ls -d */ | xargs -iA cp file.txt A |
Copies file 'file1' to each of directories 'dir1', 'dir2', 'dir3'. | echo dir1 dir2 dir3 | xargs -n 1 cp file1 |
Copies file 'fileName.txt' to each of directories listed in the 'allFolders.txt' list. | cat allFolders.txt | xargs -n 1 cp fileName.txt |
Copies file 'index.html' to each top-level directory in the current directory. | find . -mindepth 1 -maxdepth 1 -type d| xargs -n 1 cp -i index.html |
Copies file 'index.html' to each top-level directory in the current directory beginning with 'd'. | find . -mindepth 1 -maxdepth 1 -type d| grep \/a |xargs -n 1 cp -i index.html |
Copy file 'src' to 'dest', except if 'dest' already exists. | cp -n src dest |
Copies files 'src/prog.js' and 'images/icon.jpg' with fully-defined path to '/tmp/package' directory. | cp --parents src/prog.js images/icon.jpg /tmp/package |
Copies file 'test' to each of directories like './fs*/*'. | echo ./fs*/* | xargs -n 1 cp test |
Copy file header.shtml to directories dir1, dir2, dir3, and dir4 | find dir1 dir2 dir3 dir4 -type d -exec cp header.shtml {} \; |
copy the file header.shtml to those dirs | find dir1 dir2 dir3 dir4 -type d -exec cp header.shtml {} \; |
Copy file or directory 'gtest' from directory 'include' in current directory to /usr/include, preserving ownerships and permissions. | sudo cp -a include/gtest /usr/include |
Copy file or folder linked to by "file" to "file" | cp -rf --remove-destination `readlink file` file |
(Linux specific) Copy loadable kernel module "mymodule.ko" to the drivers in modules directory matchig current kernel. | sudo cp mymodule.ko /lib/modules/$(uname -r)/kernel/drivers/ |
Copy local file "$1" to host "$2" into host directory "$3" | cat $1 | ssh $2 "mkdir $3;cat >> $3/$1" |
Copies newest file under the current folder to the '/tmp/' | cp $(ls -1tr * | tail -1) /tmp/ |
Copy the owner and group of "oldfile" to "newfile" | chown --reference=oldfile newfile |
Copy permissions from "version2/somefile" to "version1/somefile" | chmod --reference version2/somefile version1/somefile |
Copy recursively "/source/backup" to "/destination" preserving symbolic links, modification times, and permissions | rsync -rtvpl /source/backup /destination |
Copy recursively "tata/" to "tata2/" and remove read, write, and execute permission for other | rsync -avz --chmod=o-rwx -p tata/ tata2/ |
Copy src_dir recursively to dest_dir, but without overwriting existing files. | cp -nr src_dir dest_dir |
Copy the standard output of a "bash" session to "/var/log/bash.out.log" | bash | tee /var/log/bash.out.log |
Correct permissions for directories in the web directory | find /your/webdir/ -type d -print0 | xargs -0 chmod 755 |
Correct permissions for files in the web directory | find /your/webdir -type f | xargs chmod 644 |
Count the *.html files residing in the /usr/src directory tree and containing string "foo" | find /usr/src -name "*.html" -exec grep -l foo '{}' ';' | wc -l |
Count the *.html files residing in the /usr/src directory tree and containing string "foo" | find /usr/src -name "*.html" | xargs grep -l foo | wc -l |
Counts all *.mod files in a /boot/grub/ folder. | ls -l /boot/grub/*.mod | wc -l |
Counts all business days in a current month. | cal -h | cut -c 4-17 | tail -n +3 | wc -w |
Count all directories in maximum 1 level down the current directory | find . -maxdepth 1 -type d -exec ls -dlrt {} \; | wc --lines |
Counts all files in a DIR_NAME folder and subfolders. | find DIR_NAME -type f | wc -l |
Counts all files in a current folder and subfolders. | find -type f -printf '\n' | wc -l |
Counts all files in a current folder and subfolders. | find . -type f | wc -l |
Counts all files in a current folder and subfolders. | find `pwd` -type f -exec ls -l {} \; | wc -l |
Count all files under "/DIR" | find /DIR -type f -print0 | tr -dc '\0' | wc -c |
count all the html files having a specifc word in a folder. | find /usr/src -name "*.html" -exec grep -l foo '{}' ';' | wc -l |
Count all the lines of all '*.c' files in current directory recursively | find . -name "*.c" -print0 | xargs -0 cat | wc -l |
Count all the lines of all files with names ending with 'php' in current directory recursively | find -name '*php' | xargs cat | wc -l |