nl_command
stringlengths 14
387
| bash_code
stringlengths 0
532
|
---|---|
Print the files in the current directory as a list of semicolon separated values | ls -m | tr -d ' ' | tr ',' ';' |
Search the files from the current directory tree for "chrome" | find . -exec grep chrome {} + |
Rename all regular files under current directory tree with inode number 31467125 to 'new_name.html' | find . -type f -inum 31467125 -exec mv {} new_name.html \; |
Checks compressed file integrity. | bzip2 -t file.bz2 |
Find all *.* directories under /home/feeds/data directory | find /home/feeds/data -type d \ -prune -o -name '*.*' -print |
Display list of files ending with '.txt' in the current folder to the terminal twice and output it to the text file "txtlist.txt" | ls *.txt | tee /dev/tty txtlist.txt |
check find version | find --version |
Find all files under current directory that were modified in the last 24 hours and also include the files that were modified in less than 1 day ago | find -daystart -mtime +0 |
Get IP address of your SSH session | who am i --ips|awk '{print $5}' #ubuntu 14 |
Recursively removes all empty folders from the X folder. | find X -depth -type d -exec rmdir {} \; |
find the count of text files that are present in the current working directory. | find . -maxdepth 1 -name \*.txt -print0 | grep -cz . |
Find all the files/directories under '/var/adm' directory tree that have not been modified in the last 3 days | find /var/adm -mtime +3 -print |
get second-to-last comma-separated field of each line in file.txt | cat file.txt | rev | cut -d ',' -f 2 | rev |
Make 999 folders one inside another where first 998 of them is named as "folderX" where X goes from 1 to 998 and the last folder named as "folder9991000" | mkdir -p folder$1000 |
Copy all files matching "*failed.ipynb" in the current directory tree to "./fails" preserving the directory hierarchy | find . -name "*failed.ipynb" | cpio -pd ./fails |
Search the home directory tree for all .txt files | find ~/ -name '*.txt' |
Find all files/directories in level 1 down the $queue directory with all positional parameters appended with the find command | echo "$queue" | xargs -I'{}' find {} -mindepth 1 -maxdepth 1 $* |
Find recursively all regular files in the current directory tree not ending in .dll or .exe | find . -type f | grep -vP "\.dll$|\.exe$" |
Find all files/directories under '/var/log' directory tree that bave been modified today (from the start of the day) | find /var/log -daystart -mtime 0 |
Print every 4th line from 10 lines of "y" with line numbers | yes | cat -n | head -10 | awk 'NR % 4 == 1' |
Find all files/directories named 'game' under current directory tree | find . -name game |
Find all files/directories in directories/files taken from the glob pattern '/tmp/test/*' recursively that have not been modified from the start of the day | find /tmp/test/* -daystart -mtime +0 |
Unzip and untar "myarchive.tar.gz" and check for corruption | gunzip -c myarchive.tar.gz | tar -tvf - |
Print "$line" in hexadecimal 2-byte units | echo -n $line | od -x |
Print second section of data coming from stdin where sections are separated by one or more whitespace. | tr -s ' ' | cut -d ' ' -f 2 |
Display process information with full command lines. | top -b -n1 -c |
Exits from screen session. | exit |
Find all *.c files located under /home and below | find /home -name "*.c" |
Find the top 25 files according to their size in the current directory and its subdirectories | find . -type f -exec ls -al {} \; | sort -nr -k5 | head -n 25 |
Remove newline characters from "yourfile.txt" | tr -d '\n' < yourfile.txt |
create a compressed archive excluding the directories containing "exclude.tag" | tar -czf backup.tar.gz --exclude-tag-all=exclude.tag /path/to/backup |
Find UTF-8 files with BOM | find -type f -print0 | xargs -0 grep -l `printf '^\xef\xbb\xbf'` | sed 's/^/found BOM in: /' |
display all the files in the file system which belong to the user "user1" | find / -user user1 |
Create 6-letter named temporary file in a folder path that is provided as the first positional parameter, and save the path to it in a variable 'tmpfile' | tmpfile=$(mktemp $(dirname "$1")/XXXXXX) |
display all the regular/normal files in the current folder excluding the files "bbb" and "yyy" | find . \ -prune -o -type f -print |
Find all files/directories that do not contain 'photo' in their names under current directory tree | find . ! -name "*photo*" |
Find all empty directories recursively starting from the current one and delete them | find . -type d -empty -print0 | xargs -0 /bin/rmdir |
Identify CMS version/releases accross all your Wordpress websites | find /var/www/vhosts/*/httpdocs/ -type f -iwholename "*/wp-includes/version.php" -exec grep -H "\$wp_version =" {} \; |
Make directory "/tmp/new" | mkdir /tmp/new |
Find all the files in the current directory recursively whose permissions are not 777 | find . -type f ! -perm 777 | head |
Compress all ".txt" files in the current directory tree with gzip | find . -type f -name "*.txt" -exec gzip {} \; |
display the version of find command | find -version |
create a backup of all the files in the current folder to the floppy and save the file list in the file /tmp/BACKUP.LOG | find . -cpio /dev/fd0 -print | tee /tmp/BACKUP.LOG |
Find a single file called tecmint.txt and remove it | find . -type f -name "tecmint.txt" -exec rm -f {} \; |
delete all instances of the file "bad" if its size is 0 bytes | find . -name bad -empty -delete |
Find all regular files with '.r' and '.c' in their names under current directory tree | find ./ -type f \ -print |
Decompress "path/to/test/file.gz" to standard output and save all lines matching "my regex" to files with a 1000000 line limit | gzip -dc path/to/test/file.gz | grep -P --regexp='my regex' | split -dl1000000 - file |
Search for 'Processed Files' in all dl-aster-full-20131102* files under current directory and print only the 2nd field from the output with : as the delimiter | | cut -d":" -f2 |
find all files in current folder having the name pattern "some_pattern" and move them to the folder target_location (GNU VERSION) | find . -name some_pattern -print0 | xargs -0 -i mv {} target_location |
Display all files in a folder | find /usr/X11/man/man5 -print |
Search directory tree `MyApp.app' for directories whose name is 'Headers' and delete them | find MyApp.app -name Headers -type d -exec rm -rf "{}" \; || true |
Execute 'echo -e "\tHello World"' every 2 seconds | watch 'echo -e "\tHello World"' |
search for a word in all the files in the current directory | find . -exec grep chrome {} \; |
Search the current directory tree for filenames matching the pattern '[mM][yY][fF][iI][lL][eE]*' | find . -name '[mM][yY][fF][iI][lL][eE]*' |
Print string "123" once with '1' replaced by 'a' and second time replaced by 'b' | echo 123 | tee >(tr 1 a) | tr 1 b |
Forward port 12345 bound on 'localhost' to port 12345 on 'otherHost' as user 'otherUser' | ssh -f -N -L localhost:12345:otherHost:12345 otherUser@otherHost |
Change all "JPG" filename suffixes in current directory to "jpeg". | rename -v 's/\.JPG/\.jpeg/' *.JPG |
Remove all .php files in the /var/www/ directory | find /var/www/*.php -type f -exec rm {} \; |
Find all .php files starting from the root directory and ignoring /media | find / -name "*.php" -print -o -path '/media' -prune |
Run 'otherscript.sh' script with all environment variables specified in the file 'xxxx' | env `cat xxxx` otherscript.sh |
Find all empty files starting from the current directory and delete them | find . -type f -empty -delete |
Retrieve column number from column name "Target" in file "table" | head -1 table | tr -s ' ' '\n' | nl -nln | grep "Target" | cut -f1 |
Delete all files in the /myDir directory tree that were last modified 7 days ago | find /myDir -mtime 7 -exec rm -rf {} \; |
Search everywhere for directories named `root' | find / -type d -name root |
Opens menu item 'Basic Shell Features' -> 'Shell Expansions' -> 'Filename Expansion' -> 'Pattern Matching' in the 'bash' manual. | info bash 'Basic Shell Features' 'Shell Expansions' 'Filename Expansion' 'Pattern Matching' |
Show current date in "%Y-%m-%d" format | date "+%Y-%m-%d" |
List all files in the "test" directory tree except those with '/invalid_dir/' in the pathnames | find test -print | grep -v '/invalid_dir/' |
Save full path of command "mktemp" to variable "MKTEMP" | MKTEMP=`which mktemp` |
List all files in the current directory tree that were modified 60 minutes ago | find -mmin 60 |
Create a symbolic link in the current directory to "../config/init" | ln -s "../config/init" |
Install 'mono-devel' package, answering 'yes' for all questions. | yum -y install mono-devel |
Print mount point of the file system containing $path. | df -P "/tmp" | awk 'BEGIN {FS="[ ]*[0-9]+%?[ ]+"}; NR==2 {print $NF}' |
display all the text files and hidden files in the home folder | find ~ -name "*.txt" — print -o -name ".*" — print |
Send uncompressed contents of "large_file.gz" to "largesplitter" | zcat large_file.gz | largesplitter |
Unsets random one from first four array members. | unset array[`shuf -i 0-3 -n1`] |
Find every vim undo file in the current directory tree | find -type f -iname '*.un~' |
Search all *.c files from the current directory tree for "hogehoge" | find . -name \*.c -print | xargs grep hogehoge |
Creates 5-letter random file name and saves it in 'rand_str' variable. | rand_str="$(mktemp --dry-run XXXXX)" |
Find the file with inode number 211028 in the current dirrectory tree and move it to newname.dir | find . -inum 211028 -exec mv {} newname.dir \; |
Forward port 16186 on hello.com to 8888 on localhost using private key "privatekeystuffdis88s8dsf8h8hsd8fh8d" for login | ssh -N -i < -R 16186:localhost:8888 hello.com |
find all the regular/normal files in the current folder and replace everything expect the extension of the file and display unique file extensions | find . -type f | sed -e 's#.*\$#\1#' | sort | uniq |
Search for files/directories that are readable for everybody, have at least one write bit set but are not executable for anybody | find . -perm -444 -perm /222 ! -perm /111 |
Md5sum the last 5 files in /directory1/directory2/ | find /directory1/directory2/ -maxdepth 1 -type f | sort | tail -n 5 | xargs md5sum |
Unzip all files matching "test1/*/*.gz" | gunzip test1/*/*.gz |
Find all directories named $1 under $HOME directory tree and remove them | find $HOME -type d -name $1 -exec echo {} ';' -exec rm -rf {} ';' |
List the files from the current directory tree that contain lines approximately matching regular expression '^Subject:.*unique subject' | find . -type f -print | xargs agrep -2 -il '^Subject:.*unique subject' |
Find all *.cgi (case insensitive) files/directories under current directory and change their permission to 755 | find . -iname '*.cgi' | xargs chmod 755 |
Create intermediate directories as required and directory /tmp/test/blah/oops/something | mkdir -p /tmp/test/blah/oops/something |
Mount all filesystems in /etc/fstab | sudo mount -a |
Display a long listing of all 0777 permission directories under current directory tree | find . -perm 0777 -type d -exec ls -l {} \; |
Print the entire saved command history | history |
split file /etc/gconf/schemas/gnome-terminal.schemas into pieces per 1000000 lines | split -n 1000000 /etc/gconf/schemas/gnome-terminal.schemas |
Find all the files whose name is tecmint.txt | find . -name tecmint.txt |
display all scala files in the directory "src/main" | find . -path "*src/main*" -type f -iname "*\.scala*" |
A no-op on filename with sed | sed -i "s/\\\\\n//g" filename |
Make directories "./es/es_MX.utf8/LC_MESSAGES" as needed and do not error if it exists | mkdir --parents ./es_MX.utf8/LC_MESSAGES |
Archive "/home/user1" to "wobgalaxy02:/home/user1" excluding hidden files | rsync -av /home/user1 wobgalaxy02:/home/user1 |
display all the files having spaces in the current folder | find . -name "filename including space" |
List the 10 largest files or directories and their sizes under (and including) "/var" | du -a /var | sort -n -r | head -n 10 |
Find all TXT files in the current directory and copy them to directory "$HOME/newdir" | find "$HOME" -name '*.txt' -type f -print0 | sort -zu | xargs -0 cp -t "$HOME/newdir" |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.