![]() |
|
Bash Tricks Cheatsheet - Be a Bash Wizard! - Printable Version +- Sinisterly (https://sinister.li) +-- Forum: Computers (https://sinister.li/Forum-Computers) +--- Forum: Operating Systems (https://sinister.li/Forum-Operating-Systems) +--- Thread: Bash Tricks Cheatsheet - Be a Bash Wizard! (/Thread-Bash-Tricks-Cheatsheet-Be-a-Bash-Wizard) |
Bash Tricks Cheatsheet - Be a Bash Wizard! - kalkin - 04-17-2012 Hi all ![]() I don't know if anybody post this before or not (i didn't find it in the list atleast :nono: ) so i'd make it for you guys whoever wants to use these. These are some tricks to use BASH and other *nix utilities in the best way possible to ease up your terminal jobs ![]() So here it is: Create iso image of cd/dvd Code: dd if=/dev/cdrom of=~/cdimage.isogeoip information Code: curl -s ifconfig.me|tee >(xargs geoiplookup)convert html links into plain text with link anchor Code: sed 's!<[Aa] *href*=*"\([^"]*\)"*>\([^<>]*\)</[Aa]>!\1,\2!g' links.htmlcopy hybrid iso images to USB key for booting from it, progress bar and remaining time are displayed while copying Code: pv -petrs $(stat -c %s file.iso) file.iso | dd bs=1M oflag=sync of=/dev/sdXRemove a range of lines from a file Code: perl -i -ne 'print if $. == 3..5' <filename>Remove a range of lines from a file Code: vi +{<end>..<start>}d +wq <filename>Transfer a file to multiple hosts over ssh Code: pscp -h hosts.txt -l username /etc/hosts /tmp/hostsCompletely blank a disk Code: dd if=/dev/urandom of=/dev/somediskCode: shred --iterations=N /dev/sdaXReplace duplicate files by hardlinks Code: fdupes -r -1 Neu | while read line; do j="0"; buf=""; for file in ${line[*]}; do if [ "$j" == "0" ]; then j="1"; buf=$file; else ln -f $buf $file; fi; done; donetell if a port is in use Code: netstat -a --numeric-ports | grep 8321regex for turning a URL into a real hyperlink (i.e. for posting somewhere that accepts basic html) Code: sed "s/\([a-zA-Z]*\:\/\/[^ ]*\)\(.*\)/\<a href=\"\1\"\>\1\<\/a\>\2/"Daemonize nc - Transmit a file like a http server Code: while ( nc -l 80 < /file.htm > : ) ; do : ; done &vim read stdin Code: ls | vim +'set bt=nowrite' -Copy all files, including hidden files, recursively without traversing backward Code: cp -r * .??* /destlist with full path Code: ls -a | sed "s#^#${PWD}/#"Show what PID is listening on port 80 on Linux Code: fuser -v 80/tcpFix MP3 tags encoding (to UTF-8). Batch fixes all MP3s in one directory. Code: find . -iname "*.mp3" -execdir mid3iconv -e <encoding> {} \;Show which user has the most accumulated login time Code: ac -p | sort -nk 2 | awk '/total/{print x};{x=$1}'convert ascii string to hex Code: python -c 'print "hello".encode("hex")' So here was the list of tricks, some i discovered, most i found on various websites looking for shortcuts to "get a bash life" hope they will be useful to someone! Sorry but i have not mentioned tit-bits above (like "replace this port # with your own" and so and so) so this list might not be noob friendly. but i guess you can figure them all out.It's 3:00 *AM* here right now. Imagine a half-sleepy dead guy tapping madly at his keyboard :headbash: get you more linux/programming/hacking tips and tricks soon! ![]() cheers!
|