misc
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| misc [2012/10/14 08:29] – paulsmith | misc [2013/02/21 09:52] (current) – paulsmith | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ====== misc ====== | ||
| + | |||
| + | ===== umount nfs mount that server disappeared ===== | ||
| + | < | ||
| + | mount local the ip off the server that disappeared: | ||
| + | |||
| + | ifconfig eth0: | ||
| + | umount -f -l / | ||
| + | ifconfig eth0: | ||
| + | </ | ||
| + | |||
| + | ===== list listened ports ===== | ||
| + | < | ||
| + | netstat -ltnup | ||
| + | </ | ||
| + | |||
| + | ===== script to copy files ===== | ||
| + | This script copies files from one location to another building the same directory structure. | ||
| + | < | ||
| + | #!/bin/bash | ||
| + | |||
| + | TARGETDIR=/ | ||
| + | |||
| + | copyfiletotarget() { | ||
| + | dir=${1%/*} | ||
| + | #echo $TARGETDIR$dir | ||
| + | mkdir -p $TARGETDIR$dir | ||
| + | cp -pR $1 $TARGETDIR$1 | ||
| + | } | ||
| + | |||
| + | copyfiletotarget / | ||
| + | copyfiletotarget / | ||
| + | copyfiletotarget / | ||
| + | copyfiletotarget / | ||
| + | copyfiletotarget / | ||
| + | copyfiletotarget / | ||
| + | copyfiletotarget / | ||
| + | copyfiletotarget / | ||
| + | copyfiletotarget /etc/hosts | ||
| + | copyfiletotarget /etc/iscsi | ||
| + | copyfiletotarget / | ||
| + | copyfiletotarget / | ||
| + | copyfiletotarget /etc/nut/ | ||
| + | copyfiletotarget / | ||
| + | copyfiletotarget / | ||
| + | copyfiletotarget / | ||
| + | copyfiletotarget / | ||
| + | copyfiletotarget / | ||
| + | copyfiletotarget / | ||
| + | copyfiletotarget / | ||
| + | copyfiletotarget / | ||
| + | |||
| + | </ | ||
| + | |||
| + | ===== simple rename ===== | ||
| + | < | ||
| + | for f in ?.jpg; do mv " | ||
| + | for f in ??.jpg; do mv " | ||
| + | for f in ???.jpg; do mv " | ||
| + | </ | ||
| + | |||
| + | ===== simple zip a set of files ===== | ||
| + | < | ||
| + | for f in net-acct-*; do gzip " | ||
| + | </ | ||
| + | |||
| + | ===== unzip files create a directory to put them in ===== | ||
| + | < | ||
| + | for f in *.zip; do a=`/ | ||
| + | </ | ||
| + | |||
| + | ===== touch all files and subdirectories ===== | ||
| + | < | ||
| + | find . -exec touch {} \; | ||
| + | </ | ||
| + | |||
| + | ===== cp files from find/grep results to a directory ===== | ||
| + | < | ||
| + | find ~/somedir/ | grep .mkv | xargs -i cp -v {} / | ||
| + | </ | ||
| + | |||
| + | ===== cv (strip comments from a file) ===== | ||
| + | < | ||
| + | grep -vE ' | ||
| + | </ | ||
| + | |||
