nl_command
stringlengths 14
387
| bash_code
stringlengths 0
532
|
---|---|
Find all *.xml files under current directory | find -name *.xml |
Archive any files changed in the last day from "remote_host" to "local_dir" | rsync -av remote_host:'$' local_dir |
List files and directories recursively | find . -print | xargs ls -gilds |
List all leaf directories of the current directory tree | find . -type d -links 2 |
Change the permissions of the current directory and all its subdirectories to 755. | find . -type d -exec chmod 755 {} \; |
Identify CMS version/releases accross all your PHPBB installations | find /var/www/vhosts/*/httpdocs/ -type f -wholename *includes/constants.php -exec grep -H "PHPBB_VERSION" {} \; |
Run a shell with all environment variables specified in the file 'cronenv' in the user's home directory. | env - `cat ~/cronenv` /bin/sh |
Remove "_dbg" from all file or directory names under the current directory | rename _dbg.txt .txt **/*dbg* |
Prints all business days in a current month. | cal -h | cut -c 4-17 |
display all the files in the /usr folder which have the permissions 777 | find /usr -perm 0777 -print |
split content of the file file.txt started from second line into pieces per 4 lines named as split_NNN | tail -n +2 file.txt | split -l 4 - split_ |
Find all files in the home directory tree that are owned by another user | find ~ ! -user ${USER} |
Change to folder where the oracle binary is. | cd "$(dirname $)" |
Set variable "b" to the first word of "a" converted to lowercase. | b=`echo "$a" | awk '{ print tolower }'` |
display all the files in the current folder excluding the current folder and do not search in the sub directories | find . -maxdepth 1 -type d \ |
Creates temporary folder in a TMPDIR folder or /tmp folder if TMPDIR doesn`t defined, with folder name like current shell name and 10-letter suffix, and saves created path in 'mydir' variable. | mydir=$(mktemp -d "${TMPDIR:-/tmp/}$.XXXXXXXXXXXX") |
Find all files that are set group ID to 10 | find . -group 10 -perm -2000 -print |
Search the current directory tree for *.conf and *.txt files | find . -type f \ -print |
display all the files in current folder which have not been modified in the last 7 days | find . -mtime +7 |
Saves date of the first Sunday in month $mo of year $yo in the 'do' variable. | do=$ |
Output the standard input followed by the line number until line 786 | nl -ba | sed 786q | grep . | awk '{print $2$1}' |
Find all directories under current directory with 755 permission and change their permission to 644 | find . -perm 755 -exec chmod 644 {} \; |
Lists installed packages from 'fedora' repository only. | yum list installed --disablerepo="*" --enablerepo="fedora*" |
List each file or directory in the current directory prefixed by its human readable filesize and sorted from largest to smallest | du -h --max-depth=0 * | sort -hr |
Find files in the current directory and below that are less than 500 kB in size | find . -size -500k -print |
Save absolute path of "$path" that may not exist to variable "abspath" | abspath=$(readlink -m $path) |
Recursively change the owner and group of all files in "/your/directory/to/fuel/" to "nginx" | chown nginx:nginx /your/directory/to/fuel/ -R |
Count non-blank lines in a file 'foo.c' | sed '/^\s*$/d' foo.c | wc -l |
Find all directories under /path/to/base/cache, /path/to/base/tmp, /path/to/base/logs and change their permission to 755 | find /path/to/base/cache /path/to/base/tmp /path/to/base/logs -type d -exec chmod 755 {} + |
Count files in $DIR_TO_CLEAN that are older than $DAYS_TO_SAVE days | find "$DIR_TO_CLEAN" -mtime +$DAYS_TO_SAVE | wc -l |
Clone the permissions of "$srcdir" to "$dstdir" on OSX | chown $ "$dstdir" |
display all the files with the names "name1" and "name2" in the current folder and do not search in the sub directories | find . -maxdepth 1 -name "name1" -o -name "name2" |
Print the list of files and directories of the /etc directory | find /etc/. ! -name /etc/. |
Display environment variable "_" of the current shell | set | grep "^_=" |
Search /etc for files modified within the last 10 minutes | find /etc -type f -mmin -10 |
Copy *.txt files from the dir/ directory tree along with their parent directories | find dir/ -name '*.txt' | xargs cp -a --target-directory=dir_txt/ --parents |
Print help on 'cat' command usage | cat --help |
Find recursively regular files in the current directory tree | find . -type f -print |
Search the current directory tree for the files with extension "trc" and remove them if they are more than three days old | find . -name "*.trc" -ctime +3 -exec rm {} \; |
Get a detailed list of all files on the system larger than 10MB | find / -size +10M -printf “%12s %t %h/%fn” |
Print a random number from 2000 to 65000 | seq 2000 65000 | sort -R | head -n 1 |
Search the current directory recursively for regular files last accessed less than 2 minutes ago | find . type -f -amin -2 |
Make all directories in the current directory tree accessible to anybody | find . -type d -print0 | xargs -0 chmod go+rx |
Disable exiting the shell on error | set +e |
Display differences between list of files in /bin and /usr/bin. | diff < < |
find all the ogg files in the current directory which have the word "monfichier" in their name | find -name *monfichier*.ogg |
Generate UUIDs for the files from the current directory tree | find . -printf "%P\n" | sort | while IFS= read -r f; do echo "$ $f"; done |
Add read and execute permission to command "node" | sudo chmod +rx $(which node) |
find all directories in the current folder | find -type d |
find all the files older than 30 days | find /tmp -mtime +30 -print |
Print the files in the current directory as a list of comma separated values | ls -1 | tr '\n' ',' | sed 's/,$/\n/' |
Expand bash array "myargs" as arguments to "mv" | mv "${myargs[@]}" |
Traverse the filesystem just once, listing setuid files and directories into /root/suid.txt and large files into /root/big.txt. | find / \( -perm -4000 -fprintf /root/suid.txt '%#m %u %p\n' \) , \( -size +100M -fprintf /root/big.txt '%-10s %p\n' \) |
list all javascipts file expect files under proc folder | find . -type d -name proc -prune -o -name '*.js' |
Print the names of all files from the /tmp/dir1 directory tree | find /tmp/dir1 -exec basename {} \; |
Print nothing because 'MYVAR' string doesn`t match with '/[^/]+:' pattern | echo MYVAR | grep -oE '/[^/]+:' | cut -c2- | rev | cut -c2- | rev |
Display the total count of all the files/directories with '.old' extension under current directory tree | find . -name “*.old” -print | wc -l |
Find all directories starting from the current directory | find . -type d |
Find all files named 'file' in 1 level down the current directory whose status were changed more than 1 day ago | find . -maxdepth 1 -ctime +1 -name file |
find all the files that have been modified in the last 24 hours | find . -type f -mtime -1 |
Gives longest '*.php' files with line count first, and excludes directories with "libs", "tmp", "tests" and "vendor" in their paths. | find . -name '*.php' | xargs wc -l | sort -nr | egrep -v "libs|tmp|tests|vendor" | less |
find all files in the current folder that are modified exactly 2 minutes ago | find -mmin 2 -print |
Remove all files and directories under '/home/foo' directory tree that match with one of the name patterns '.DS_Store', '._.DS_Store' , '._*', '.TemporaryItems' or '.apdisk' | find /home/foo \( -name '.DS_Store' -or -name '._.DS_Store' -or -name '._*' -or -name '.TemporaryItems' -or -name '.apdisk' \) -exec rm -rf {} \; |
Print the list of all directories under the current directory and below | find ./ -type d -print |
Read a line from standard input with prompt "Are you alright? (y/n) " and save the response to variable "RESP" | read -p "Are you alright? (y/n) " RESP |
search for the file foo in the current folder and display a long listing of it in sorted order of modification date | find . -name foo | xargs ls -tl |
Convert "595a" into characters and then print the hexadecimal and printable characters of each byte | echo 595a | awk -niord '$0=chr("0x"RT)' RS=.. ORS= | od -tx1c |
Print days between date $A and $B | echo " / " | bc -l |
Remove files from the file system that are owned by nobody | find / -nouser -exec rm {} \; |
Find all files/directories that are bigger than 100 bytes under '/home/apache' directory tree | find /home/apache -size 100c -print |
Find all filename.* files/directories under /root/directory/to/search | find /root/directory/to/search -name 'filename.*' |
Locate all .txt files in and below the current directory | find . -name "*.txt" |
Save the directory of the full path to the current script in variable "dir" | dir=$(dirname $) |
Replace all newlines except the last with a comma in "test.txt" | sed -i ':a;N;$!ba;s/\n/,/g' test.txt |
Recursively removes all files like '._*' from current folder. | find . -name "._*" -print0 | xargs -0 rm -rf |
Print only lines from 'file1.txt' that not present in 'file2.txt' and beginning with 'Q' | cat file1.txt | grep -Fvf file2.txt | grep '^Q' |
Print the list of files in the home directory tree whose names begin with "Foto" | find ~ -name 'Foto*' |
change the permissions of all the regular/normal files to 664 in the current folder | find . -type f -exec chmod 664 {} \; |
Find files/directories containing 'test' in their names and display the directory contents before the directories themselves | find -name "*test*" -depth |
List environment variables whose name contains "X" | set | cut -d= -f1 | grep X |
Set variable "fname" to the basename of path specified in variable "f", that is remove everything up to the last slash if present. | fname=`basename $f` |
Display standard input as octal bytes | cat | od -b |
List files larger than 10MB under /var/log /tmp that haven't changed in a month | find /tmp /var/tmp -size +30M -mtime 31 -ls |
Find all files with name "file.ext" under the current working directory tree and print each full path directory name | find `pwd` -name file.ext |xargs -l1 dirname |
find all text files in the current folder excluding those that are presenti n the folder "/svn" and search for a pattern. | find . -name '*.txt' \! -wholename '*/.svn/*' -exec grep 'sometext' '{}' \; -print |
Change owner of "my_test_expect.exp" to "el" | sudo chown el my_test_expect.exp |
Set variable 'rav' to the contents of 'var' spelled backwards. | rav=$(echo $var | rev) |
find from / a file called 'toBeSearched.file', suppressing any error messages | find /. -name 'toBeSearched.file' 2>/dev/null |
remove all the core files in the current directory | /bin/find -name "core" — exec rm {} \; |
Find all 100MB files in file system and delete them using rm command | find / -size +100M -exec rm -rf {} \; |
Run sed command "s#\(export\ PATH=\"\)\(.*\)#\1/home/$(whoami)/bin:~/\.local/bin:\2#" on "~/.zshrc" where "$(whoami)" is replaced with the current user name | sed -i "s#\(export\ PATH=\"\)\(.*\)#\1/home/$(whoami)/bin:~/\.local/bin:\2#" ~/.zshrc |
Find all your text files and page through them | find . -name "*.txt" -print | less |
List all crons in the environment | cat /etc/passwd | sed 's/^\([^:]*\):.*$/crontab -u \1 -l 2>\&1/' | grep -v "no crontab for" | sh |
Find all files/directories named 'file_name' under current directory tree | find . -name file_name |
list *.pdf, *.bmp and *.txt files under the /home/user/Desktop directory. | find /home/user/Desktop -name '*.pdf' -o -name '*.txt' -o -name '*.bmp' |
find all the files in the folder /path/to/dir which have been modified after a specific date | find /path/to/dir -newermt “Feb 07” |
Find files/directories named 'document' in the entire filesystem and in the directory tree '/usr' even if it's in a different partition without traversing to other devices/partitions | find / /usr -xdev -name document -print |
Replace each non-blank line in "YOURFILE" preceded with "pX=" where "X" is the line number | grep -v '^$' YOURFILE | nl -s= -w99 | tr -s ' ' p |
Find x* files/directories under /tmp directory whose status was changed less than 1 day ago and move them to ~/play | find /tmp/ -ctime -1 -name 'x*' -print0 | xargs -r0 mv -t ~/play/ |
Find all *.log files under path/ that do not contain "string that should not occur" | find path/ -name '*.log' -print0 | xargs -r0 grep -L "string that should not occur" |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.