nl_command
stringlengths 14
387
| bash_code
stringlengths 0
532
|
---|---|
Go to directory pointed by last element of array "dirs" in bash version 4.2 | cd "${dirs[-1]}" |
Search the current directory tree for files and directories with permissions 775 | find . -perm 775 -print |
Report total file systems disk usage estimated in terabytes | df --total -BT | tail -n 1 |
Prints calendar of $month, $year, and redirects all output to the awk script 'cal.awk', with predefined variable 'day=$day'. | cal $month $year | awk -v day=$day -f cal.awk |
find all files in the current folder which have only the write permission for the others | find . -perm -0002 -print |
Archive directory specified by variable "i" to "/iscsi" preserving relative paths. | rsync -avR $i /iscsi; |
Search current directory for any directory named "config" and go to first match found. | cd "$(find . -name config -type d | sed 1q)" |
Finds recursion-related options of a 'grep' utility. | grep --help |grep recursive |
list all files under $dir directory except path $dir/prune_me directory | find "$dir" -not \ -exec bash -c 'echo "$0"' {} \; |
Find file `hosts' | find /etc -name hosts |
Execute '/usr/bin/fbi -noverbose -a -t 4 -u `find -type f | egrep -i "$"`' every 300 seconds and display without title | watch -n 300 -t '/usr/bin/fbi -noverbose -a -t 4 -u `find -type f | egrep -i "$"`' |
Save absolute path of the script filename in variable "SCRIPT" | SCRIPT="$" |
Prints yesterday's date information | date --date yesterday "+%a %d/%m/%Y" |
Save "$N" number of '.' characters in variable "myvar" | myvar=`seq 1 $N | sed 's/.*/./' | tr -d '\n'` |
Display the last space-separated field of each line in file.txt | rev file.txt | cut -d ' ' -f1 | rev |
Recursively removes all files with name like "myFile.*" in 'file path' folder. | find <file path> -name "myFile.*" -exec rm -f {} ; |
list all active jobs and its IDs | jobs -l |
display all the files in the home folder excluding directories which have been modified in the last 24 hours | find /home/ -mtime -1 \! -type d |
Print the contents of "~/.ssh/config" | cat ~/.ssh/config |
Change permissions of all directories from the current directory tree to 644 | find . -type d -exec chmod 755 {} + |
Find all files that were modified later than ordinary_file in the current directory and its sub-directories. | find -newer ordinary_file |
display all the directories in the current folder excluding those that are present in the .svn directory tree | find -type d -path '.svn' -prune -o -print |
Convert Unix `cal` output to latex table code. | cal -h 02 2012| cut -c4-17 | sed -r 's/(..)\s/\0\t\&/g' | sed 's/$/\t\\\\/' | head -n-1 | tail -n +2 |
Send SIGKILL signal to process ID 16085, killing it instantly. | kill -9 16085 |
Installs package "devtoolset-3" answering 'yes' on all questions. | yum install -y devtoolset-3 |
Count the number of symbolic links starting from /students | find /students -type l -print 2> /dev/null |wc -l |
Opens new tmux session. | tmux |
Find all *.py files under current directory and run 'perl script.pl' with the file paths as arguments | find . -name '*.py' | xargs perl script.pl |
Set the host name to the contents of "/etc/hostname" | hostname $(cat /etc/hostname) |
Search the directory tree /tmp for regular files using zero delimiter for output | find /tmp -type f -print0 |
Find all *.ogg and *.mp3 files/directories under your home directory | find $HOME -iname '*.ogg' -o -iname '*.mp3' |
find all the directories in the current folder | find . -type d -print |
Find all regular files under $DIRECTORY_TO_PROCESS matching the case insensitive regex ".*\.$FILES_TO_PROCES" where $FILES_TO_PROCES is a variable and not matching the name pattern '$find_excludes' where $find_excludes is another variable, then print the files with null delimiter instead of newline | find "$DIRECTORY_TO_PROCESS" -type f -iregex ".*\.$FILES_TO_PROCES" ! -name "$find_excludes" -print0 |
List files in directory "one" that exist in directory "two" | sort < < | uniq -d |
Search the /tmp/ directory recursively for regular files | find /tmp -type f |
Find and remove zero bytes files from user's directories . | find /usr/* -size 0c -exec rm {} \; |
find al the files that are modified exactly 2 days ago | find -daystart -mtime 2 |
delete all the empty files in the current directory only if they are ok and the user has the permission to delete them | find . -empty -ok rm {}\; |
search for files with the name "temp" in the /usr folder | find /usr -name temp -print |
Count the number of .gz files in directory tree /home/user1/data1/2012/mainDir | find /home/user1/data1/2012/mainDir -name '*.gz' | wc -l |
search for files which are writable by either their owner or their group | find . -perm /u=w,g=w |
Search the current directory tree for *cache, *xml, and *html files | find . -type f \( -name "*cache" -o -name "*xml" -o -name "*html" \) |
Find all directories under /myfiles directory | find /myfiles -type d |
Print permissions of every directory in the current directory tree | tree -p -d |
Compare "$source_file" and "$dest_file" line by line | diff "$source_file" "$dest_file" |
Print the directories that are taken by the glob pattern $SrvDir* | find $SrvDir* -maxdepth 0 -type d |
Find all hidden files under /tmp | find /tmp -type f -name ".*" |
Continuously send "a" then "b" to "script.py" | yes $'a\nb' | script.py |
Print characters 2 through 4 of "abcdefg" | echo 'abcdefg'|tail -c +2|head -c 3 |
Find all Subscription.java files/directories under current directory and enter into the parent directory of the first one found | cd $ |
Terminate amarok immediately. | kill -9 $ |
Save a unique list of the currently logged in usernames to variable "line" | line=$(who | cut -d' ' -f1 | sort -u) |
Find all SGID files in entire file system | find / -perm +g=s |
Read a line of standard input with prompt "Enter your choice: " in an interactive shell and save the response to variable "choice" | read -e -p "Enter your choice: " choice |
Remove last two underscore-delimited fields and following characters in "t1_t2_t3_tn1_tn2.sh" keeping only "t1_t2_t3" | echo t1_t2_t3_tn1_tn2.sh | rev | cut -d_ -f3- | rev |
Print the list of the subdirectories of /path/to/dir | find /path/to/dir/ -mindepth 1 -maxdepth 1 -type d |
Find all .core files on the system starting from / and delete them | find / -name "*.core" | xargs rm |
Find all files named "something" in the current folder and below and run them through the ls -l command, one by one. | find . -name something -exec ls -l {} \; |
List the unique second "/" delimited field of every line from standard input prefixed by the number of occurrences | cut -d/ -f1-2 | cut -d/ -f2- | sort | uniq -c |
ERROR - need to add -a or -r for recursive copy | rsync --exclude='B/' --exclude='C/' . anotherhost:/path/to/target/directory |
Find all 777 permission directories and use chmod command to set permissions to 755 | find / -type d -perm 777 -print -exec chmod 755 {} \; |
Find and remove the file with inode number 782263 in the current directory tree | find . -inum 782263 -exec rm -i {} \; |
Save the current user name in variable "myvariable" | myvariable=$ |
Find all directories by the name `httpdocs' on the system | find / -type d -name httpdocs 2> /dev/null |
find all foo.bar files in the entire file system and which are present in the same partition as root. | find / -name foo.bar -print -xdev |
Report file system containing path to /dir/inner_dir/ disk usage human-readable. | df -h /dir/inner_dir/ |
Overwirte file '/path/to/your/file' with random content, then overwrite with zeroes, and remove, showing progress while execution. | shred -v -n 1 -z -u /path/to/your/file |
Find the top 5 biggest files | find . -type f -exec ls -s {} \; | sort -n -r | head -5 |
Recursively change owner and group of "/usr/local/rvm/gems/ruby-2.0.0-p481/" to the current user | sudo chown $:$ /usr/local/rvm/gems/ruby-2.0.0-p481/ -R |
find all the cpp files in current folder | find -name "*.cpp" |
List all regular files under the current directory and below it | find . -type f -print0 | xargs -0 ls -l |
display a long list of all the jpg files in the home folder | find ~ -iname '*.jpg' -exec ls {} \; |
Find all regular .html files in the /var/www directory tree | find /var/www -type f -name "*.html" |
Perform a case insensitive search for *filename* files/directories under current directory tree | find . -iname "*filename*" |
Search all files in the current directory tree, except *.html and *.svn*, for "SearchString" | find . ! -name '*.html' ! -name '*.svn*' -exec grep 'SearchString' {} /dev/null \; |
Calculate the md5 sum of all *.py files in the current directory | cat *.py | md5sum |
Count the number of lines in all ".php" files in the current directory tree | find . -name '*.php' -type f | xargs cat | wc -l |
recursively delete, without prompting, directories under /data/bin/test, that are older than 10 days and where the name starts with a number | find /data/bin/test -type d -mtime +10 -name "[0-9]*" -exec rm -rf {} \; |
Find all directories starting from YOUR_STARTING_DIRECTORY that contain the string "99966" in their names | find YOUR_STARTING_DIRECTORY -type d -name "*99966*" -print |
Send reverse requests to get domain name for each address in 'my_ips' list | cat my_ips | xargs -i dig -x {} +short |
Recursively change the owner group of "/var/www" of to "www-data" | sudo chown -R www-data:www-data /var/www |
Ensure all 5 of UEDP0{1..5}_20120821.csv files exist, creating empty files for any missing ones (updates the file's timestamps) | touch -a UEDP0{1..5}_20120821.csv |
find in the file system for the directories with the name "httpdocs" | find / -type d -name 'httpdocs' |
Find all *.old files and move them to directory oldfiles | find . -name "*.old" -exec mv {} oldfiles \; |
Find all files/directories under $1 which have at least execute permission for their owner and set execute permission for group for these files/directories | find "$1" -perm -u+x -print0 | xargs chmod g+x |
set alias "ls" for command "ls -lrta" | alias ls='ls -lrta' |
Find all files/directories that contain 'packet' (case insensitive) in their names excluding directories that are bigger than 1500 bytes in size | find . -iregex ".*packet.*" ! -type d -size +1500c |
Display a garbled ascii-art of a cow saying "hello" backwards | cowsay "hello" | rev |
Mount "/dev/shm" using /etc/fstab entry | mount /dev/shm |
find all files in the home folder which are modified in the last 2 days. | find ~ -type f -mtime -2 |
Send ping requests to "yourhostname.local" | ping youhostname.local |
Unzip every ".gz" file in the current directory tree | find . -name "*.gz" | xargs gunzip |
display all the regular/normal files in the current folder which have been modified in the last 24 hours | find . -mtime 0 -type f |
Lists all files that matches path pattern with wildcards. | ls -l /lib*/ld-linux*.so.2 |
List files in the current directory that have at least one duplicate | md5sum * | sort | uniq -w32 --all-repeat=separate | awk '{print $2}' |
display all regular/normal files in the current folder with the name dummy | find -type f -name dummy |
Print 10 lines of a single "x" | yes x | head -n 10 |
Search in the current directory and all sub-directories except ./D for the file named hi.dat. | find . \( -name D -prune \) -o -name hi.dat |
Checks compressed file integrity. | bzip2 -t file.bz2 |
Copies '[MacVim_source_folder]/src/MacVim/mvim' to the '/usr/local/bin', printing info message on each operation. | cp -v [MacVim_source_folder]/src/MacVim/mvim /usr/local/bin |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.