Official site launch very soon, hurrah!
Find will search through a directory and its subdirectories for objects (files, directories, links, etc) satisfying its parameters.Parameters are written like a math query, with parenthesis for order of operations (make sure to escape them with a “\”!), -a for boolean “and”, -o for boolean “or”, and ! for “not”. If neither -a or -o is specified, -a is assumed.For example, to find all files that contain “conf” but do not contain “.bak” as the extension, OR are greater than 5MB:find -type f \( \( -name "*conf*" ! -name "*.bak" \) -o -size +5120k \)Some useful parameters include:-maxdepth & -mindepth: only look through certain levels of subdirectories-name: name of the object (-iname for case insensitive)-regex: name of object matches regular expression-size: size of object-type: type of object (block special, character special, directory, named pipe, regular file, symbolic link, socket, etc)-user & -group: object is owned by user/group-exec: exec a command on found objects-print0: output each object separated by a null terminator (great so other programs don’t get confused from white space characters)-printf: output specified information on each found object (see man file)For any number operations, use:+nfor greater than n-nfor less than nnfor exactly than nFor a complete reference, see your find’s man page.
xargs passes piped arguments to another command as trailing arguments.For example, to list information on all files in a directory greater than 1MB: (Note this will not work with paths with spaces in them, use “find -print0” and “xargs -0” to fix this)find -size +1024k | xargs ls -lSome useful parameters include:-0: piped arguments are separated by null terminators-n: max arguments passed to each command-i: replaces “{}” with the piped argument(s)So, for example, if you had 2 mirrored directories, and wanted to sync their modification timestamps:cd /ORIGINAL_DIRECTORYfind -print0 | xargs -0 -i touch -m -r="{}" "/MIRROR_DIRECTORY/{}"For a complete reference, see your xargs’s man page.
GREP is used to search through data for plain text, regular expression, or other pattern matches. You can use it to search through both pipes and files.For example, to get your number of CPUs and their speeds:cat /proc/cpuinfo | grep MHzSome useful parameters include:-E: use extended regular expressions-P: use perl regular expression-l: output files with at least one match (-L for no matches) -o: show only the matching part of the line-r: recursively search through directories-v: invert to only output non-matching lines-Z: separates matches with null terminatorSo, for example, to list all files under your current directory that contain “foo1”, “foo2”, or “bar”, you would use:grep -rlE "foo(1|2)|bar"For a complete reference, see your grep’s man page.
#!/bin/bashexport IFS=$'\n' #Forces only newlines to be considered argument separatorsfor dir in `find -type d -maxdepth 1`do a=`find $dir -type f | wc -l`; if [ $a != "0" ] then echo $dir $a fidone
find -maxdepth 1 -mindepth 1 -type d -print0 | xargs -i -0 sh -c "echo -n {} \" \"; find \"{}\" -type f | wc -l"
objdump -p $1 | grep -Pzo '(?is)^\[Ordinal/Name Pointer\] Table.*?\n\n' | grep -oP '(?<=\d\] ).*$'
for i in $@; do echo -e "--------\n$i\n--------"; get_dll_exports $i; done
for i in $@; do echo -n "$i: "; get_dll_exports $i | perl -pe 's/\n/ /' -; echo; done
echo -e '\0033\0143'
AppDirectory='/cygdrive/c/Users/Administrator/AppData/Local/Plex Media Server/';sqlite3 "$AppDirectory/Plug-in Support/Databases/com.plexapp.plugins.library.db" 'SELECT file, title, MDI."index", hints FROM media_parts AS MP INNER JOIN media_items AS MI ON MI.id=MP.media_item_id INNER JOIN metadata_items AS MDI ON MDI.id=MI.metadata_item_id;'[/code
find -type d -exec sh -c 'test `find "{}/" -mindepth 1 -type d | wc -l` -eq 0' ';' -print
find -links +1 | xargs -d"\n" ls -i | perl -e 'foreach $Line (<STDIN>) { @Cols=($Line=~/^\s*(\d+)\s*(.*?)\s*$/); push(@{$Link{$Cols[0]}}, $Cols[1]); } foreach $List (values %Link) { print join("\t", @{$List})."\n"; }'
#Dump from sqlite (DB should be in C:\Users\USERNAME\AppData\Local\Plex Media Server\Plug-in Support\Databasessqlite3 com.plexapp.plugins.library.db 'select file, updated_at from media_parts' | \sort | uniq | perl -pe 's/\\/\//g' | perl -pe 's/^\w:/\./gi' | perl -pe 's/\|/\t/g' | \grep -viP '^((DRIVES_TO_IGNORE):|\./(DIRECTORIES_TO_IGNORE)|\|$)' > NAME_CHECKS#Find all files with their modification timestampsfind -L -type f -printf "%p\t%TY-%Tm-%Td %TH:%TM:%.2TS\n" | sort > FTIMES2#Filter out unwanted folders and file extensions. I did this as a separate command from the above line to allow filtering without having to run a find on the entire drive againcat FTIMES2 | grep -vP '\.(md5|torrent|sub|idx|nfo|srt|txt|ssa|log|db|jpg|tbn|sfv|png|cbz|rar|cbr|OTHER_EXTENSIONS)\t' | grep -vP '^./(System Volume Information|\$RECYCLE\.BIN|OTHER_FOLDERS)/' > FTIMES#After comparing the 2 files and extracting any files that need to be updated, run this regular expression on the data to get touch commands to update the timestamps^(.*)\t\d\d(\d\d)-(\d\d)-(\d\d) (\d\d):(\d\d):(\d\d)$ => touch -m -t $2$3$4$5$6.$7 "$1"
auditctl -a exit,always -S execve -F uid=USERNAME
ausearch -m ALL | perl -0777 -e 'print grep(/uid=USERID/, grep(!/REGEX/im, split(/^----$/m, <>)))'
function ReplaceVar() { REPLACE_VAR_NAME="$1"; REPLACE_VAR_VAL=$(echo "$2" | perl -e '$V=<STDIN>; chomp($V); print quotemeta($V)' -); perl -pi -e "s/(?<=$REPLACE_VAR_NAME[ \t]*=).*$/$REPLACE_VAR_VAL/" "$3"}