nl_command
stringlengths 14
387
| bash_code
stringlengths 0
532
|
---|---|
prints the last non-empty line of a file | tac FILE |egrep -m 1 . |
Move all files and directories not starting with "l" in "/mnt/usbdisk" to "/home/user/stuff/." | mv /mnt/usbdisk/[^l]* /home/user/stuff/. |
display all the files in the entire file system which are bigger than 10MB | find / -size +10000k |
Format time string @$TIMESTAMP according to default time format | date -d @$TIMESTAMP |
Find all files named `file1' on the system | find / -name file1 |
Send command to named screen session with special characters | screen -x $PROCESS -p 0 -X stuff `printf "stop\r"` |
Print out the names of broken symlinks in the current directory | for l in $; do cd $; if [ ! -e "$(readlink $)" ]; then echo $l; fi; cd - > /dev/null; done |
Find files on the system that are bigger than 20 megabytes and show the sorted list of their filenames | find / -type f -size +20000k -exec ls -lh {} \; 2> /dev/null | awk '{ print $NF ": " $5 }' | sort -nrk 2,2 |
Recursively change the ownership of all directories in the current directory excluding "foo" to "Camsoft" | ls -d * | grep -v foo | xargs -d "\n" chown -R Camsoft |
Find all the files whose permissions are 777 under current directory | find . -type f -perm 0777 -print |
Find all files under /path/to/dir that were modified less than 7 days ago with null character as the delimiter | find /path/to/dir -type f -mtime -7 -print0 |
Remove all *.sql files in the $backup_path directory tree that were last modified more than 30 days ago | find $backup_path/* -name *.sql -mtime +30 -exec rm {} \; |
print all the files in the current folder which do not begin with a capital letter | find . \! -name '[A-Z] *' -exec lpr { }\; |
Creates temporary file and saves path to it in a 'tmpfile' variable. | tmpfile=`mktemp` |
Locate all *.mov files in the current directory tree | find . -name '*.mov' |
Search the dir_data directory and all of its sub-directories for regular files and remove the execute permission for all while adding the write permission for the user. | find ~/dir_data -type f -exec chmod a-x,u+w {} \; |
Print numbers from 1 to 5 without separating spaces | seq 5 | awk '{printf "%s", $0} END {print ""}' |
Update timestamps of all files under current directory. Also works on older Unix systems with obsolete 'find' command. | find . -print -exec touch {} \; |
Display the mount point of a device file "$path" | mount | grep "^$path" | awk '{print $3}' |
Save IP address of your SSH session in variable "WORKSTATION" | WORKSTATION=`who -m|awk '{print $5}'|sed 's/[]//g'` |
Find all broken symlinks under current directory | find -xtype l |
Find *.html files in the /usr/src/linux directory tree | find /usr/src/linux -name "*.html" |
display a long listing of all the log files in the current folder which are bigger than 1MB | find . -size +1000k -name *.log -print0 | xargs -0 ls –lSh |
display all the files in current folder which have not been modified in the last 7 days | find . -mtime +7 |
Compare the contents of gzip-ompressed files "file1" and "file2" | diff < < |
Create symbolic link "$1/link" to the absolute path of "$2" | ln -s "$" "$1/link" |
Remove "_dbg" from all file or directory names under the current directory | rename _dbg.txt .txt **/*dbg* |
Send "yes" 4 times followed by 1 "no" to "./script" | { yes yes | sed 4q; yes no | sed 1q; } | ./script |
find all files in the current directory do not display the files which do not have read permission to all users | find . ! -perm -g+r,u+r,o+r -prune |
Search for files/directories which are writable by somebody (their owner, or their group, or anybody else) | find . -perm /222 |
Search the home directory tree for video files | find ~ -type f -name '*.mkv' -o -name '*.mp4' -o -name '*.wmv' -o -name '*.flv' -o -name '*.webm' -o -name '*.mov' |
Print the names of the directories from the paths expanded by the glob pattern /path/to/directory/* | find /path/to/directory/* -maxdepth 0 -type d -exec basename {} \; |
Print fourth column of space-separated data from text file text.txt. | cat text.txt | cut -d " " -f 4 |
List the current directory recursively ignoring ./src/emacs/ and all its contents | find . -path ./src/emacs -prune -o -print |
Send one ping request to host with local address in the 192.168.1.x range, with last number specified by variable "COUNTER", and output only lines containing "ms" to standard output. | ping -c 1 192.168.1.$COUNTER | grep 'ms' |
Find all directories under /home/me/"$d" | find /home/me/"$d" -type d |
Find files/directories that does not have write permssion for group | find /path ! -perm /g+w |
Print the icmp sequence number and ping time of each request to "127.0.0.1" | ping -c 2 -n 127.0.0.1 | awk -F'[ =]' -v OFS='\t' 'NR>1 { print $6, $10 }' |
Find grub.conf files in entire file system discarding errors | find / -name grub.conf 2>/dev/null |
Find all *.txt files/directories under your home directory | find ~ -name "*.txt" -print |
Write standard input to standard output and file "/tmp/arjhaiX4" | tee /tmp/arjhaiX4 |
Copy directory tree preserving UID and GID and leaving user files alone | find . -depth -print | cpio -o -O /target/directory |
Search for files/directories which are writable by either their owner or their group | find . -perm /u+w,g+w |
change the owner and group of all the files in the folder /usr/lpp/FINANCIALS | find /usr/lpp/FINANCIALS -print | xargs chown roger.staff |
Show all of the .conf files in Pat's user folder and subdirectories using the less pager | find /home/pat -iname "*.conf" | less |
Print the list of all directories in the /myfiles directory tree | find /myfiles -type d |
Display file status for each regular file in the current directory tree | find . -type f -exec stat {} \; > /dev/null |
display all the files in the file system which belong to the user "wnj" and which are modified after the file "ttt" | find / -newer ttt -user wnj -print |
Generate a random 32 ASCII character password from /dev/urandom and save it to variable 'pass' | pass=$(LC_CTYPE=C < /dev/urandom tr -cd [:graph:] | tr -d '\n' | fold -w 32 | head -n 1) |
Print IP addresses of the host name | hostname -I | awk '{print $1}' |
Synchronize "/path/to/dir_b" with files in "/path/to/dir_a/" if the files are newer | rsync -rtuv /path/to/dir_a/* /path/to/dir_b |
Recursively removes all files like '*.pyc' of '*.pyo' in a current folder without prompting. | find . -type f -name "*.py[c|o]" -exec rm -f {} + |
List file contents of compressed file 'compressed.tar.gz' | gzip -l compressed.tar.gz |
Removes any empty folder that matches pattern ed*. | rmdir ed* |
Delete all files named '-F' under current directory tree | find . -name "-F" -exec rm {} \; |
Find all the files on the system that have been accessed within the last hour | find / -amin -60 |
Make directories to "/my/other/path/here" as needed | mkdir -p /my/other/path/here |
Find recursively all files whose names ends with "foo" | find . -name "*foo" |
Find files in the /travelphotos that are greater than 200k in size but do not have "2015" anywhere in the file name | find /travelphotos -type f -size +200k -not -iname "*2015*" |
run ls command on *.pl files | find . -name "*.pl" -exec ls -ld {} \; |
Find mysong.ogg anywhere under the home directory | find $HOME -name 'mysong.ogg' |
List the abc.def files under the directories /ghi and /jkl which have commented entries and display those entries | find /ghi /jkl -type f -name abc.def 2> /dev/null -exec grep -H ^# {} \; |
search for the word "foo" in all the regular/normal files in the directory "/path/to/dir" | find /path/to/dir -type f -print0 | xargs -0 grep -l "foo" |
Print the number of entries in the subdirectories of the current directory, stopping search at any device mount points. | sudo find . -xdev -type f | cut -d "/" -f 2 | sort | uniq -c | sort -n |
Print a count of each unique line from standard input sorted from least frequent to most frequent | sort | uniq -c | sort -n |
Find all files excluding files ending with 'gz', 'tmp' and 'xftp' in their names in the current directory tree and compress them with gzip not preserving timestamp and original name | find . -type f ! \( -name "*gz" -o -name "*tmp" -o -name "*xftp" \) -exec gzip -n '{}' \; |
Find all *.py files/directories under current directory | find . -name *.py |
Find SGID files | find / -perm +g=s |
Replace any blank character from standard input with a tab | tr '[:blank:]' \\t |
Find all directories under current directory excluding those which match the regex /\. in their names | find . -type d | grep -v '/\.' |
Find files/directories that are newer than 'foo.txt' under current directory tree | find -newer foo.txt |
Prepend "foo" to the file "bar" | { echo foo; cat bar; } | tee bar > /dev/null |
Find all files/directories in the entire file system and redirect the output to masterfilelist.out file | find / -print > masterfilelist.out |
Set the history time format variable "HISTTIMEFORMAT" to "%s " and display up to event 2 | HISTTIMEFORMAT="%s " history 2 |
Search the current directory recursively for regular files with the extension given as variable $extension | find . -type f -name "*.$extension" |
find all the perl files in the current folder | find . -type f -name "*.pl" |
Find all pdf files excluding *_signed.pdf files under /some/dir with null character as the delimiter | find /some/dir -name "*.pdf" ! -name "*_signed.pdf" -print0 |
List screen session IDs | screen -list |
download contents from website "www.example.com" using URL-encoding "paramName=param" | curl --data-urlencode "paramName=param" www.example.com |
change the permission of all the directories to 755 in the current folder | find -type d -exec chmod 755 {} \; |
Find all files owned by group `root' in the current directory tree and change their user to `temp' | find . -group root -print | xargs chown temp |
Append "foo" and "bar" column in file "file" with values dependent on the current table contents | awk 'NR==1 {print $0, "foo", "bar"; next} {print $0, , }' file | column -t |
Move all regular files under current directory to ./newdir | find ./ -type f -print | xargs -l56 -I {} mv -f {} ./newdir |
Finds files in 'directory' folder with the same name and location but different content than files in 'directory.original' folder and saves location of such files to 'directories' variable. | directories=$(diff -qr directory directory.original | cut -d' ' -f2 | xargs dirname | uniq) |
search through only the /usr and /home directories for any file named Chapter1.txt | find /usr /home -name Chapter1.txt -type f |
List all broken symlinks excluding cyclic links under current directory | find . -type l -printf "%Y %p\n" | grep -w '^N' |
Print "/tmp/myfile" starting at line 11 | tail -n +11 /tmp/myfile |
Join strings from 'file1' and 'file2', discarding excessive strings from largest file, and printing first, second and third space-separated field from first file, and third and fourth field from second file as a join result | join -o 1.2,1.3,2.4,2.5,1.4 < < |
Identify CMS version/releases accross all your PHPBB installations | find /home/*/public_html/ -type f -wholename *includes/constants.php -exec grep -H "PHPBB_VERSION" {} \; |
list all files in /home/bozo/projects directory tree that were modified within the last day | find /home/bozo/projects -mtime -1 |
search for all regular/normal files in current folder and display all the files which contain 16 lines | find . -type f -print0 | xargs -0 grep -cH '.' | grep ':16$' |
Find regular files named 'findme.txt' under '/usr' and '/home' directory tree | find /usr /home -name findme.txt -type f -print |
check find version | find --version |
Recursively add ".jpg" to all files without an extension in the directory tree "/path" | find /path -type f -not -name "*.*" -exec mv "{}" "{}".jpg \; |
Find '.java' files with checksum 0bee89b07a248e27c83fc3d5951213c1 in the current directory | md5sum *.java | grep 0bee89b07a248e27c83fc3d5951213c1 |
change the permissions of all the regular files in the current folder | find . -type f -exec chmod 500 {} ';' |
Creates temporary folder in /tmp/ with 10-letter suffux. | mktemp -d -t |
Print the names and sizes of regular files residing in the "dir" directory tree | find dir -type f -printf "f %s %p\n" |
Find all directories in the current directory tree that are not accessible by all | find -type d ! -perm -111 |
Find all *.txt files under the current directory whose names are not "File.txt" | find . -maxdepth 1 -type f -name '*.txt' -not -name File.txt |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.