nl_command
stringlengths
14
387
bash_code
stringlengths
0
532
Print URL "http://www.blabla.bla/forum-detail/?ft=72260&fid=34&&pgr=" followed by a number ranging from 1 to 786
yes 'http://www.blabla.bla/forum-detail/?ft=72260&fid=34&&pgr=' | nl -ba | sed 786q | grep . | awk '{print $2$1}'
Change permissions to 700 for files and directories deeper than the current directory
find . -mindepth 2 | xargs chmod 700
Find all broken symlinks under current directory
find -L . -type l
Find all files/directories named 'FindCommandExamples.txt' under '/root' directory tree
find /root -name FindCommandExamples.txt
Find the top 5 big files
find . -type f -exec ls -s {} \; | sort -n -r | head -5
Print the sorted unique column of usernames of users who are currently logged in without the header
finger | cut -d ' ' -f1 | sort -u | grep -iv login
Find the unique owners of all the files in the /bin directory
find /bin -type f -follow | xargs ls -al | awk ' NF==9 { print $3 }'|sort -u
display all the regular/normal files in the current folder which are modified after a file
find . -type f -newer "$FILE"
locate large files (> 100 MB) in /home/ for 'cleaning'
find /home -type f -size +100M -delete
Replace all occurrences of "foo_fn" with "bar_fn" in the files named "foo_fn" from the current directory tree
find . -name foo_fn exec sed -i s/foo_fn/bar_fn/g '{}' \;
Set permissions of all files under "/opt/lampp/htdocs" to 644
find /opt/lampp/htdocs -type f -exec chmod 644 {} \;
find all the core files in the entire file system and delete them
find / -name core -exec rm -f {} \;
display all files in current folder excluding text files
find . ! -name "*.txt"
find all files in the current folder which have not been accessed in the last 30 days in the current folder
find . -atime +30 -print
Returns unsuccessful exit code on each found file like '*tests*' within current directory.
find . -name '*tests*' -print -exec false \;
display all the files in the current folder excluding search in the paths containing the folder having the word "mmm"
find . ! -path *mmm*
Print the current directory tree
tree
Remove all vmware-*.log files under current directory ensuring white space safety in filename
find . -name vmware-*.log -print0 | xargs -0 rm
Removes only lowest level subfolders from current directory tree .
find . -type d | xargs rmdir
Prints full path to files in a current folder.
ls -d -1 $PWD/**
Print out the contents of all *.txt files in the home directory
find ~/ -name '*.txt' -exec cat {} ;
Save Maven project version to variable "version"
version=$
Find all files modified less than 5 minutes ago, and page interactively through the output.
find -cmin -5 | less -R
Find regular files under / that contain "stringtofind"
find / -maxdepth 1 -xdev -type f -exec grep -li stringtofind '{}' \;
Find all .mp3 files starting from the current directory
find . -type f -iname *.mp3
Print the 5th space separated fields in "file" as a comma separated list
cut -d' ' -f5 file | paste -d',' -s
List all available commands in Mac OS
echo $PATH | tr ':' '\n' | xargs -I {} find {} -maxdepth 1 -type f -perm '++x'
Print the contents of "Little_Commas.TXT"
cat Little_Commas.TXT
Sends current job to the background.
bg
List all *.txt files/directories under /etc
find /etc -name "*.txt" | xargs -I {} ls -l {}
Set variable value to current kernel release name, making this variable visible by subprocesses of current shell.
export value=$
List all files from the current directory tree that were modified less than 60 minutes ago
find . -mmin -60 | xargs -r ls -ld
Change all cron jobs running "anm.sh" to be run every 10 minutes instead of 5 minutes.
crontab -l | sed '/anm\.sh/s,^\*/5,*/10,' | crontab -
Find all files/directories under current directory and print only 2nd field from output delimited by '/'
find . | awk -F"/" '{ print $2 }'
Start a VLC process with a dummy interface in the background, immune to SIGHUP signals, to play all media files in mp3_directory from the user's home directory.
nohup vlc -I dummy --quiet ~/mp3_directory/* &
Archive directory "tata" to directory "tata2", compressing data during copy.
rsync -avz tata/ tata2/
display all files in the current folder which are not empty
find . ! -size 0k
Output all lines that have a common first colon-separated field in files 'selection2.txt' and 'selection1.txt' by displaying the common field of each line, followed by the extra fields in both lines.
join -t: selection2.txt selection1.txt
Get the sizes (and total size) of all files under dir2 directory
find dir2 ! -type d |xargs wc -c
Find a file/directory named modules under current directory and exit with the number of files/directories named 'modules' found in this path
find . -name modules -exec sh -c 'exit $' \;
Find all filenames ending with .c in the current directory tree, case insensitive
find -iname "*.c"
Search the current directory tree for symbolic links to files matching pattern '*test*'
find . -lname '*test*'
Get the list of regular files in the current directory
find . -mindepth 1 -maxdepth 1 -type f -print0 | xargs -0 -I {} echo "{}"
Compress "my_large_file" with gzip and split the result into files of size 1024 MiB with prefix "myfile_split.gz_"
gzip -c my_large_file | split -b 1024MiB - myfile_split.gz_
gives the chars in line 5 and chars 5 to 8 of line 5, in tst.txt
head -5 tst.txt | tail -1 |cut -c 5-8
Write standard output and error to the console and append to file "log"
./aaa.sh |& tee -a log
Invoke a trusted X11 forwarding SSH connection with server "192.168.0.14" on port 222 as user "phil"
ssh -v -Y [email protected] -p 222
Find all files/directories in all paths expanded by the glob pattern *
find *
print all files in the current directory and all subdirectories
find .
Print every 20 bytes of standard input as tab separated groups of bytes 1-3, 4-10, and 11-20
fold -b -w 20 | cut --output-delimiter $'\t' -b 1-3,4-10,11-20
search for the directory starting with "ora10" in the entire file system
find / -type d -name "ora10*"
Find all files under and below /dir that were accessed less than 60 minutes ago
find /dir -amin -60
Remove the regular files from the current directory tree that are newer than /tmp/date.start but not newer than /tmp/date.end
find ./ -type f -newer /tmp/date.start ! -newer /tmp/date.end -exec rm {} \;
Determine DISPLAY variable for the session when logged in via SSH
who am i | awk '{print $5}' | sed 's/[()]//g' | cut -f1 -d "." | sed 's/-/./g'
display all text files in the folder /tmp/1 excluding those which do not have spaces in their names
find /tmp/1 -iname '*.txt' -not -iname '[0-9A-Za-z]*.txt'
Find directories in the current directory recursively that are not "executable" by all
find -type d ! -perm -111
Lists all directories in '/home/alice/Documents/'.
ls -d /home/alice/Documents/*/
Rename all files in the current directory to the md5 sum followed by the extension and print the conversions
md5sum * | sed -e 's/\([^ ]*\) \(.*\(\..*\)\)$/mv -v \2 \1\3/e'
Find all *.c files on the system and feed the output to wc
find / -name *.c | wc
Change to the directory containing the "oracle" executable
cd "$(dirname "$(which oracle)")"
Display the sizes and filepaths of all files/directories sorted in ascending order of size
du -a --max-depth=1 | sort -n
Page through the disassembler output of objdump on executable file 'my-crashing-program'.
objdump --disassemble my-crashing-program | less
List all files in /var/www and below that have changed in the last 10 minutes
find /var/www -cmin -10 -printf "%c %pn"
Removes all empty folders under path '/foo/bar' and the path itself.
find /foo/bar -type d -depth -exec rmdir -p {} +
Perform syntax check on all PHP files in the current directory tree
find . -name \*.php -type f -exec php -l {} \;
Find all btree*.c files under current directory
find . -type f -name 'btree*.c'
display the contents of all the text files in the current directory
find . -name '*.txt' -exec cat {} \;
Search the /path directory tree for files missing g+w and o+w bits
find /path ! -perm /022
List all files and directories in the /home directory tree whose names are "Trash"
find /home -name Trash -exec ls -al {} \;
Find all files under current directory and show their file information
find . -type f -print0 | xargs -0 file
Display differences between a and b side-by-side
diff -y a b
Search the home directory tree for files modified less than 7 days ago
find $HOME -mtime -7
Locates 'gcc' executable file, strips last two parts of the full path, adds '/lib' to the end and saves result in 'libdir' variable.
libdir=$(dirname $(dirname $))/lib
Monitor all processes whose command includes 'java'.
top -p "$"
Run 'command', pausing and waiting for user interaction after each page of output.
command | more
Finds PIDs of ssh sessions of all logged in users.
pgrep -u w | grep ssh| awk '{print $1}' ssh
Remove duplicates in variable "variable" and preserve the order
variable=$
Find all regular files newer than '/tmp/$$' (where $$ expands to current process id) under '/tmefndr/oravl01' directory tree
find /tmefndr/oravl01 -type f -newer /tmp/$$
display all file in the folder /dir/to/search except ".c" files
find /dir/to/search/ \! -name "*.c" print
Search the current directory for files whose names start with "messages." ignoring SVN, GIT, and .anythingElseIwannaIgnore files
find . -type f -print0 | xargs -0 egrep messages. | grep -Ev '.svn|.git|.anythingElseIwannaIgnore'
find md5sum of an empty string
echo -n '' | md5
Change permissions of "/usr/bin/wget" to 777
chmod 777 /usr/bin/wget
Find files ending in "config"
find . -path '*/*config'
Find all files/directories named 'query' (case insensitive) under current directory
find -iname "query"
Find all files/directories under current directory tree
find | xargs
Find all files/directories under current directory tree that belong to user 'john'
find . -user john
List the number of occurrences of each unique character in "The quick brown fox jumps over the lazy dog" sorted from most frequent to least frequent
echo "The quick brown fox jumps over the lazy dog" | grep -o . | sort | uniq -c | sort -nr
For each item in array "alpha", display the basename, that is the part following the last slash, or the whole item if no slash is present.
basename -a "${alpha[@]}"
change owner and group of the file script.sh to user root
chown root:root script.sh
find all the configuration files which have been accessed in the last 30 minutes.
find /etc/sysconfig -amin -30
split all files in directory "/dev/shm/split/" into pieces per 1000 lines
find /dev/shm/split/ -type f -exec split -l 1000 {} {} \;
List the z* links in the /usr/bin directory with inode information and the file to which it points to
find /usr/bin -type l -name "z*" -ls
Remove all files and directories called "test" from the current directory tree
find . -name test -exec rm -R "{}" \;
Locate all *.mov files in the current directory tree
find . -name '*.mov'
Test if a file named 'file' in the current directory is more than 1 hour old
find file -prune -cmin +60 -print | grep -q .
Write the common third space separated fields in "file1.sorted" and "file2.sorted" to "common_values.field"
comm -12 <(cut -d " " -f 3 file1.sorted | uniq) <(cut -d " " -f 3 file2.sorted | uniq) > common_values.field
find all the files which are of size 0 bytes.
find . -type f -empty
Search for $GROUP at the beginning of each line in /etc/group and print the last colon separated entry with comma replaced with newlines
grep ^$GROUP /etc/group | grep -o '[^:]*$' | tr ',' '\n'
find all the regular/normal files ending with ".mod" in a folder and send them as input to the remodup command
find $DIR -name "*.mod" -type f -exec remodup {} \;
Look for SGID files and directories
find / -perm /g=s