nl_command
stringlengths 14
387
| bash_code
stringlengths 0
532
|
---|---|
Verbosely compresses all files on seventh and eighth depth level keeping original files in place. | bzip2 -kv */*/*/*/*/*/*/* |
Lists all files and folders with its content in a current folder, excluding names starting with 'b'. | ls ! |
find all files in the current folder which have not been accessed in the last 7 days or which are bigger than 20KB | find . -atime +7 -o -size +20480 -print |
display the contents of all the regular files in the current folder and save the output to out.txt | find . -type f | xargs cat > out.txt |
Find all files/directories with space in their names under /tmp/ directory and rename them by replacing all spaces with _ | find /tmp/ -depth -name "* *" -execdir rename " " "_" "{}" ";" |
Find all directories under minimum 1 level down the $GIVEN_DIR directory | find "$GIVEN_DIR" -type d -mindepth 1 |
SSH with parameters specified in "$@" using key file "~/.ssh/gitkey_rsa" | ssh -i ~/.ssh/gitkey_rsa "$@" |
login as user root | su -l |
Find all files under /path/to/Dir and set their permission to 644 | sudo find /path/to/Dir -type f -print0 | xargs -0 sudo chmod 644 |
Print second section of space-separated data coming from stdin. | cut -d ' ' -f 2 |
Find all $1 files/directories under current directory and enter into the parent directory of the first one found | cd $(dirname $) |
Get the base filename from variable 'path', similar to using the basename command. | echo "$path" | rev | cut -d"/" -f1 | rev |
Find all directories in maximum 1 level down the current directory and remove the . entry from the output | find . -maxdepth 1 -type d | sed '/^\.$/d' |
Find all 777 permission files in entire file system and set permissions to 644 | find / -type f -perm 0777 -print -exec chmod 644 {} \; |
Print the login time and user of the first person who logged in | who | awk '{print $3 " " $4 " "$1}' | sort | head -1 |
search for the file picasso in the folder /home/calvin/ (case insensitive search) | find /home/calvin/ -iname “picasso” |
find files in current folder ending with ".c" or ".h" or ".ch" and search for a word in these files and enable color highlighting of the matched text | find . -name "*.[ch]" -exec grep --color -aHn "e" {} \; |
Search for the string "ERROR" in all XML files in the current working directory tree | find . -name "*.xml" -exec grep "ERROR" /dev/null '{}' \+ |
search for a word in all the regular/normal files in the current folder and display the filename along with the matched text | find . -type f -exec grep -l linux {} \; |
Print the path to the pipe created for process substitution | echo <(true) |
create a link to all the html or htm files in the current folder which have been changed in the last 30*24 hours | find \( -name "*.htm" -o -name "*.html" \) -a -ctime -30 -exec ln {} /var/www/obsolete \; |
find all the files in the file system which belong to the groep "users" and with the name "dateiname" | find / -group users -iname "Dateiname" |
Update the history file in the current session | history -w |
Find all *foo files/directories under current directory (error prone) | find . name *foo |
Find all files/directories named 'foo.bar' in the entire filesystem | find / -name foo.bar -print |
Replace 'company' with 'newcompany' in all files under current directory | find ./ -type f -exec sed -i 's/company/newcompany/' {} \; |
Runs `file' on every file in or below the current directory. | find . -type f -exec file '{}' \; |
Look for files in the current directory tree to which the group users have full access | find . -perm -070 -print |
Change directory to the directory containing file path "$1" | cd "$(dirname "$1")" |
Gets IP address of 'eth0' network interface. | ifconfig eth0 | awk '/inet /{sub; print $1}' |
Prints process tree of a bash process. | pstree $ |
Gets domain name from dig reverse lookup. | dig -x 8.8.8.8 | grep PTR | cut -d ' ' -f 2 | grep google | cut -f 5 |
Remove all files in the /myfiles directory tree that were accessed at least 30 days ago | find /myfiles -atime +30 -exec rm {} ; |
Get a detailed list of all files on the system larger than 10MB | find / -size +10M -printf “%12s %t %h/%fn” |
Compress all files with '.txt' extension under current directory | echo *.txt | xargs gzip -9 |
Search user1's home directory tree for *.bin files | find /home/user1 -name \*.bin |
Shifts the positional parameters to the left by 1. | shift |
Copy the file foo.sh into /path/to/cotainer of the docker container | tar -c -C /path/on/local/machine . | docker cp - dvc:/path/on/container |
Find all files in /mydir and replace every occurrences of <string1> with <string2> in those files invoking sed as few times as possible | find /mydir -type f -exec sed -i 's/<string1>/<string2>/g' {} + |
Find all directories whose name is root in / directory | find / -type d -name root |
Replace "dummyvalue" with the system IP address in "filename" | sed -i s/'dummyvalue'/$/g filename |
Print all lines in file that do not match "pattern" | sed -n '/pattern/!p' file |
Print a list of regular files from directory tree sort_test/ sorted with LC_COLLATE=C | find sort_test/ -type f | env -i LC_COLLATE=C sort |
list files in /usr modified after the time which /tmp/stamp$$ modified | find /usr -newer /tmp/stamp$$ |
Sets shell option 'extglob'. | shopt -s extglob |
Find all *.txt files/directories under current directory and execute process_one for each of them | find . -name "*.txt" -print0 | xargs -0 -n 1 process_one |
Find all directories in the current directory tree that were last modified more than 5 minutes ago but less than 60 minutes ago | find . -mmin -60 -mmin +5 |
Execute "ps -mo pid,tid,%cpu,psr -p \`pgrep firefox\`" every half second displayed with no title and highlighting the differences | watch -tdn0.5 ps -mo pid,tid,%cpu,psr -p \`pgrep firefox\` |
Find all files under /home/username/public_html/sites/all/modules and set their permission to 640 | find /home/username/public_html/sites/all/modules -type f -exec chmod 640 {} + |
Recursively finds all files in root folder and prints all strings with 'text-to-find-here' from that files, preceding matched string with filename. | find ~/ -type f -exec grep -H 'text-to-find-here' {} \; |
Find all files in maximum 2 levels down the current directory | find . -maxdepth 2 -type f |
Print total size of file systems in kilobytes. | df | tail -n +2 | tr -s ' ' | cut -d ' ' -f 2 | paste -s -d+ | bc |
Finds IP address of 'eth0' network interface. | ifconfig eth0 | grep 'inet addr:' | awk '{print $2}' | awk -F ':' '{print $2}' |
Display the sizes and filepaths of all files/directories sorted in descending order of size | du -a -h --max-depth=1 | sort -hr |
Delete all lines in "file" that contain "pattern", using "temp" as temporary working file . | grep -v "pattern" file > temp && mv temp file |
Find all regular files in current directory and /home/www directory | find * /home/www -type f |
Find files that were modified 7 days ago and archive them | find . -type f -mtime 7 | xargs tar -cvf `date '+%d%m%Y'_archive.tar` |
Repeat "image.png" 10 times on a single line | yes image.png | head -n10 | xargs echo |
Search for 'example' in all regular files under current directory tree and also print the filenames | find . -type f -exec grep "example" '{}' \; -print |
Save only the digits in "$filename" to variable "number" | number=$(echo $filename | tr -cd '[[:digit:]]') |
Reads content of bzip2 compressed files and processes it with awk utility. | bzip2 -dc input1.vcf.bz2 input2.vcf.bz2 | awk 'FNR==NR { array[$1,$2]=$8; next } ($1,$2) in array { print $0 ";" array[$1,$2] }' |
Find all files whose names begin with 'Makefile' in the /usr/ports directory tree and count the number of lines in them containing ^M | find /usr/ports/ -name Makefile\* -exec grep `printf '\15'` -l '{}' '+' | wc -l |
Print contents of "file" as space separated hexadecimal bytes on a single line | od -t x1 -An file |tr -d '\n ' |
Reverse the order of lines in "dax-weekly.csv" keeping the first line the same | cat dax-weekly.csv | awk '1 { last = NR; line[last] = $0; } END { print line[1]; for (i = last; i > 1; i--) { print line[i]; } }' |
find file which case-insensitive name is foo in current directory. | find . -iname foo |
search for a files "cart1" in the folder junk which is in home folder and move the folder to ~/junk/A. | find ~/junk -name 'cart1' -exec mv {} ~/junk/A \; |
Do not mark variables and function which are modified or created for export to the environment of subsequent commands | set +a |
Search for the extended regex expanded by"$MONTH\/$YEAR.*GET.*ad=$ADVERTISER HTTP\/1" in the decompressed contents of the /var/log/apache2/access*.gz files that are newer than ./tmpoldfile and older than ./tmpnewfile | find /var/log/apache2/access*.gz -type f -newer ./tmpoldfile ! -newer ./tmpnewfile \ | xargs zcat | grep -E "$MONTH\/$YEAR.*GET.*ad=$ADVERTISER HTTP\/1" -c |
change the permissions of all the regular/normal files in the current folder | sudo find . -type f -exec chmod 644 {} + |
Find all SUID set files under current directory and show a few lines of output from the beginning | find . -perm /u=s | head |
display a long listing of all regular files in current folder which have been modified in the last 60 minutes | find . -mmin -60 -type f | xargs ls -l |
Set the setgid bit on all directories in the repository "/git/our_repos" | find /git/our_repos -type d -exec chmod g+s {} + |
Save the first three octets of the host name's IP address to variable "subnet" | subnet=$ |
find all the links in somedirectory and print them in a single line (to avoid the problem of files having newline in their names) | find "somedir" -type l -print0 |
Remove trailing white spaces from all files under dir directory | find dir -type f -exec sed -i 's/ *$//' '{}' ';' |
Change the user and group of all files and directories under /var/www to www-data:www-data | find /var/www -print0 | xargs -0 chown www-data:www-data |
search for all the jpg files in the folder "/mnt/hda1/zdjecia/test1/" and create a directory in /mnt/hda1/test with the same name as the mp3 file | find /mnt/hda1/zdjecia/test1/ -type f -iname ‘*.jpg’ -printf ‘%’h’\'”0″ | xargs -0 -I ‘{}’ mkdir -p /mnt/hda1/test/{} \; |
Find and uncompress all files in the current directory tree ending in ".csv.gz" | find . -name '*.csv.gz' -print0 | xargs -0 -n1 gzip -d |
List unique series of 3 characters in file "$1" prefixed by the number of occurrences and sorted from most frequent to least frequent | fold -w3 "$1" | sort | uniq -c | sort -k1,1nr -k2 |
Print info about all mounted file systems | df |
Print the files in the current directory as a list of comma separated values | ls -1 | tr '\n' ',' |
Find all directories that do not contain "main.cpp" | diff <(find . -exec readlink -f {} \; | sed 's/\\/.*$/\1/' | sort | uniq) <(find . -name main.cpp -exec readlink -f {} \; | sed 's/\\/.*$/\1/' | sort | uniq) | sed -n 's/< \/\1/p' |
Find all .txt files in the /home/user directory tree and copy them to /home/backup | find /home/user -name '*.txt' | xargs cp -av --target-directory=/home/backup/ --parents |
Remove all files in the current directory tree that have the name "abc.xxx" | find . -name abc.xxx -exec rm {} \; |
Find all files matching "abc*" in the current directory and append a column with "OK" | find . -name 'abc*' -exec echo {}' OK' \; | column -t |
Find all foo.mp4 files in the current directory tree and print the pathnames of their parent directories | find . -name foo.mp4 -printf '%h\n' |
Delete the files under the current working directory with inode numbers specified on standard input | xargs -n 1 -I '{}' find "$" -type f -inum '{}' -delete |
Sort content of files 'file1' and 'file2' by second of dot-separated fields. | cat file1 file2 |sort -t. -k 2.1 |
Counts all files in a current folder and subfolders. | find -type f -printf '\n' | wc -l |
Print content of all files ending with '*.foo' in current directory recursively | find . -name '*.foo' -exec cat {} \; |
Search "file1" for lines matching regex patterns listed in "file2" and list the unique results (sorted alphabetically) | grep -f file2 file1 | sort -u |
Find all empty directories under current directory | find . -type d -empty |
Display differences between directories dir1 and dir2, treating absent files as empty. | diff -Naur dir1/ dir2/ |
display a long listing of all the regular/normal files in the file system which have set uid bit or set gid bit enabled. | find / -type f \( -perm -4000 -o -perm -2000 \) -exec ls -l {} \; |
Recursively find all files ending with '*.txt' and print they names and content | find . -name \*.txt -print -exec cat {} \; |
remove all the regular/normal files in the temp folder and do not delete in the sub folders | find /tmp -maxdepth 1 -type f -delete |
Prints long listing of "$dir/$file" file. | ls -l -- "$dir/$file" |
display the count of all the files in the current folder | find . -print | wc -l |
List all environment variables whose name starts with PATH, showing the name and value of each one. | env | grep ^PATH |
Search the current directory tree for files whose names end in "rb" or "js" | find . -name "*js" -o -name "*rb" |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.