nl_command
stringlengths 14
387
| bash_code
stringlengths 0
532
|
---|---|
display all files in the entire file system | find / |
search for files in the current folder which start with "myfile" | find . -iname 'MyFile*' |
Recursively change the owner of all files in "testproject/" to "ftpuser" | chown ftpuser testproject/ -R |
split compressed content of the file www into pieces per 1073741824 bytes named as "backup.tar.NNN" | tar czf - www|split -b 1073741824 - www-backup.tar. |
Append all PNG and JPG files to tar archive 'images.tar' | find . \ -print -exec tar -rf images.tar {} \; |
Finds all folders that contain 'ssh' file and have 'bin' in path. | dirname `find / -name ssh | grep bin` |
Find all *FooBar* files/directories under current directory and copy them to ~/foo/bar | find . -name '*FooBar*' -exec cp -t ~/foobar -- {} + |
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 |
Remove trailing white spaces from all files under dir directory | find dir -type f -exec sed -i 's/ *$//' '{}' ';' |
Takes folder path from string '/path/to/copy/file/to/is/very/deep/there' and created it with all parents. | mkdir -p `dirname /path/to/copy/file/to/is/very/deep/there` \ |
Find all files/directories under current directory and print their paths | find . -exec echo {} \+ |
find all the png files in current folder which are present in the pattern list file "search.txt" | find . -name '*.png' | grep -f <(sed s?^?/[0-9]_[0-9]_[0-9]_? search.txt) |
Find all files under and below /dir that were accessed less than 60 minutes ago | find /dir -amin -60 |
Archive "myfile" to "/foo/bar/" and create directory "/foo/bar/" if "/foo/" exists | rsync -a myfile /foo/bar/ |
Print list of all user names who are logged in | who | sed -e 's/[ \t].*//g' |
Find all regular files under $somedir directory and print each of their paths after a string literal 'Found unexpected file ' | find "$somedir" -type f -exec echo Found unexpected file {} \; |
Synchronize "dir_a" and "dir_b" to contain the latest files in both directories | rsync -ur dir_a dir_b && rsync -ur dir_b dir_a |
search in the current directory for any file named Chapter1.txt | find . -name Chapter1 -type f |
Find all directories under /myfiles directory | find /myfiles -type d |
find all php files in the folder /var/www/ | find /var/www/ -type f -iname "*.php" -print |
find all regular files in current directory and replace the word searc to replace in them. | find . -type f -exec sed -i 's/searc/replace/g' {} \; |
Find all executable files under current directory and reverse sort them | find . -perm -111 -type f | sort -r |
Delete all files under current directory tree with '.$1' extension where $1 expands as the first positional parameter | find . -name "*.$1" -exec rm {} \; |
Find files and directories owned by xuser1 and change their ownership to user2 | find . -user xuser1 -exec chown -R user2 {} \; |
Gets IP addresses of all active network interfaces. | ifconfig | grep -oP ".*?" |
Gets MAC address of eth0 network interface. | ifconfig | grep -i hwaddr | cut -d ' ' -f9 |
Find all *.gz files/directories under asia and emea directory | find asia emea -name \*.gz |
Set the bash environmental variable "PROMPT_COMMAND" to save the output of the last executed command to variable "LAST" and file '/tmp/x" | PROMPT_COMMAND='LAST="`cat /tmp/x`"; exec >/dev/tty; exec > >' |
Change the permission to 644 for all files under current directory | find . -type f | xargs -I{} chmod -v 644 {} |
Find all files that matches both the case insensitive patterns *$1* and *$2* under /home/musicuser/Music/ directory and execute mplayer for each of them | find /home/musicuser/Music/ -type f -iname "*$1*" -iname "*$2*" -exec mplayer {} \; |
Clear the in-memory history | history -c |
Delete everything except the control characters in "foobar\n\337" and dump the remaining characters | printf 'foobar\n\377' | tr -d '\0-\176' | od -t c |
Find all files that belong to user root | find / -user root |
Remove all files with a txt extension under current directory | find . -type f -name "*.txt" -exec rm {} \; -print |
display the version of find | find --version |
Find all *.gz files in the current directory and decompress them using gunzip | find . -name '*.gz' -print0 | xargs -0 gunzip |
find all the file that have been modified in the last 3 days ( considers day starting not 24 hours ) | find ./ -daystart -mtime -3 |
Archive "_vim/" to "~/.vim" suppressing non-error messages and compressing data during transmission | rsync -aqz _vim/ ~/.vim |
list regular file which file name end with '*.c' or '*.sh' in current directory | find . -type f \( -name "*.c" -o -name "*.sh" \) |
Check if content of all top-level *.txt files in the current directory contain only unique lines | cat *.txt | sort | sort -u -c |
Make directory "TestProject" | mkdir TestProject |
Forward all connections to client localhost 3307 via the SSH tunnel to gateway and then connect to host 1.2.3.4 to port 3306 | ssh -f user@gateway -L 3307:1.2.3.4:3306 -N |
Search for 'some string' in all *.axvw files under current directory and show the matched lines with line numbers | find . -name '*.axvw' -exec grep -n 'some string' {} + |
Locate symlinks in directory trees lpi104-6 and research/lpi104-6 | find lpi104-6 research/lpi104-6 -type l |
Search directory tree $DIR for *.txt files | find "$DIR" -name \*.txt |
Create 1000 files each file having a number from 1 to 1000 named "file000" to "file999" | seq 1 1000 | split -l 1 -a 3 -d - file |
Find all .c and .C files in the current directory tree that contain "main(" and copy them to directory test1/ | find -iname “*.c” -exec grep -l ‘main(‘ {} \; -a -exec cp {} test1/ \; |
Move all files in the current directory tree that match "some_pattern" to "target_location" | find . -name some_pattern -print0 | xargs -0 -I % mv % target_location |
Find all hidden directories starting from the current directory | find . -type d -name ".*" |
Create symbolic links in the current directory for all files excluding "CONFIGFILE" located under "/your/project" directory tree | find /your/project -type f ! -name 'CONFIGFILE' -exec ln -s \{\} ./ \; |
Replace all occurrences of 'subdomainA.example.com' with 'subdomainB.example.com' in all regular files under '/home/www' directory tree | find /home/www -type f -print0 | xargs -0 sed -i 's/subdomainA.example.com/subdomainB.example.com/g' |
Display file.txt with lines numbered, and page interactively through the result. | less -N file.txt |
Find all broken symlinks under current directory | find . -type l -xtype l |
Find all directories under /path whose names are 33 characters long | find /path -type d -printf "%f\n" | awk 'length==33' |
get the root access | sudo su |
display all normal/regular files in current folder which have readable permission | find . -type f -readable |
Print unique lines in sorted "file1" compared to sorted file "file2" | comm -23 file1 file2 |
List all functions defined in the shell | set | grep " () $" | cut -d' ' -f1 |
find the file "filename.txt" in the entire file system | find / -name filename.txt -print |
List all files in the current directory tree that were modified 60 minutes ago | find . -mmin 60 -print0 | xargs -0r ls -l |
Remove all regular files in the current directory | find ./ -type f -exec rm -rf {} \; |
Find all files which have 211028 inode number in current directory then Locating and renaming unprintable directories | find . -inum 211028 -exec mv {} newname.dir \; |
Sort file "file" by line | sort file -o !#^ |
find all files in etc which have been changed in the last 1 day | find /etc -daystart -ctime -1 |
Recursively finds all files in a current folder excluding already compressed files and compresses them with level 9. | find . -type f | egrep -v '\.bz2' | xargs bzip2 -9 & |
Find all files under relative/path/to/dir, calculate their md5sum and redirect the result to sums.md5 | find relative/path/to/dir -type f -exec md5sum {} + > sums.md5 |
Find files containing string "#!/bin/ksh" and append their names and matching strings to /tmp/allfiles | find . -type f -execdir /usr/bin/grep -iH '#!/bin/ksh' {} \; | tee /tmp/allfiles |
Find all *.foo files under current directory and search for 'bar' in those files | find . -name '*.foo' -exec grep bar {} \; |
Find all directories under foldername directory and set their permission to 755 | sudo find foldername -type d -exec chmod 755 {} ";" |
Prints sorted list of logged in users. | w -h | cut -d' ' -f1 | sort | uniq |
Print a random number from 2000 to 65000 | seq 2000 65000 | sort -R | head -n 1 |
Print new line separated numbers from "001" to "100" | yes | nl -ba | tr ' ' 0 | sed 100q | cut -b 4-6 |
Join comma-separated information in 4 files | join -t, <(sort test.1) <(sort test.2) | join -t, - <(sort test.3) | join -t, - <(sort test.4) |
Recursively list all files and directories in "coreutils-8.9" with "DIR: " prepending directory names | tree -F coreutils-8.9 | sed -r 's|── (.*)/$|── DIR: \1|' |
display all instances of "foo.cpp" file in the current folder which are not in the sub directory tree ".svn" | find . -name 'foo.cpp' '!' -path '.svn' |
find all the jpg files in a directory. | find /home -name '*.jpg |
Search the current directory tree for TXT files skipping hidden ones | find . -type f \ |
Search all directory from /usr downwards for files whose inode number is 1234 and print them . | find /usr -inum 1234 -print |
list all javascipts file which whole name does not contain excludeddir | find . -name '*.js' | grep -v excludeddir |
Delete all *.zip files under current directory that are older than 2 days | find . -name "*.zip" -mtime +2 orint0 | xargs -0 rm |
find all the mp3 files in the home folder which have been modified today | find ~ -type f -mtime 0 -iname '*.mp3' |
Find the .groovy files outside the "./target" directory path | find . -name "*.groovy" -not -path "./target/*" -print |
Find all files that were not accessed in the past 100 days | find /home -atime +100 |
display all the symbolic links in the current folder | find ./ -type l |
Create a symbolic link in the current directory for each .jpg file under "dir" | ln -s "$" . |
Print numbered list of all top-level files in the current directory, with name containing 'android' | ls | grep "android" | cat -n |
Print all files on the system owned by group `name_of_group' | find / -group name_of_group |
search for the directory "ora10" in the entire file system | find / -type d -name "ora10" |
Change the group of all directories under current directory tree to a group with the same name as the directory name | find . -type d | sed -e 's/\.\///g' -e 's/\./avoid/g' | grep -v avoid | awk '{print $1"\t"$1}' | xargs chgrp |
search for the word LOG in all the files in the folder ~/jsmith | find ~jsmith -exec grep LOG '{}' /dev/null \; -print |
Find all files/directories 1 level down the current directory and redirect the sorted output to file a | find . -maxdepth 1 | sort > a |
Connect to host "server_b" as ssh user "user" and copy local file "/my_folder/my_file.xml" to server_b's directory "/my_new_folder/". | scp -v /my_folder/my_file.xml user@server_b:/my_new_folder/ |
remove all the core files in the home folder | find /home -name core -exec rm {} \; |
Infinitely ping every host listed in "file-of-ips" with at most 50 processes at once | cat file-of-ips | xargs -n 1 -I ^ -P 50 ping ^ |
Find all files in current directory that were modified less than 1 day ago excluding hidden files and archive them to /media/caca/extract/full$date.cpio | find . -depth \ -prune -o -print| cpio -aov > /media/caca/extract/full$date.cpio |
Find files in the current directory tree that were accessed within the last 60 minutes | find . -amin -60 |
switch to user username | su username |
find all the text files in the current folder and do not search in the sub directories | find -maxdepth 1 -iname "*.txt" |
find and delete all the empty directories in the current folder and all its sub directories too | find . -depth -empty -type d -delete |
Find all files/directories that do not contain 'photo' in their names under current directory tree | find . ! -name "*photo*" |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.