[[misc]]
 

misc

umount nfs mount that server disappeared

mount local the ip off the server that disappeared:

ifconfig eth0:fakenfs 192.168.0.18 netmask 255.255.255.255
umount -f -l /my/mount/dir
ifconfig eth0:fakenfs down

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=/usr/local/vmware/custom/host1

copyfiletotarget() {
        dir=${1%/*}
        #echo $TARGETDIR$dir
        mkdir -p $TARGETDIR$dir
        cp -pR $1 $TARGETDIR$1
}

copyfiletotarget /etc/make.conf
copyfiletotarget /etc/ha.d/haresources
copyfiletotarget /etc/ha.d/authkeys
copyfiletotarget /etc/ha.d/ha.cf
copyfiletotarget /etc/ha.d/ha_logd.cf
copyfiletotarget /var/www/localhost/htdocs/index.htm
copyfiletotarget /var/www/localhost/htdocs/index.txt
copyfiletotarget /etc/conf.d/hostname
copyfiletotarget /etc/hosts
copyfiletotarget /etc/iscsi
copyfiletotarget /etc/conf.d/net
copyfiletotarget /etc/conf.d/ntp-client
copyfiletotarget /etc/nut/
copyfiletotarget /etc/samba/smb.conf
copyfiletotarget /usr/local/sbin
copyfiletotarget /etc/vmware/netmap.conf
copyfiletotarget /etc/vmware/config
copyfiletotarget /etc/vmware/license.vs.1.0-00
copyfiletotarget /etc/vmware/license.cfg
copyfiletotarget /etc/vmware/hostd/vmInventory.xml
copyfiletotarget /etc/vmware/hostd/datastores.xml

simple rename

for f in ?.jpg; do mv "$f" "000$f"; done
for f in ??.jpg; do mv "$f" "00$f"; done
for f in ???.jpg; do mv "$f" "0$f"; done

simple zip a set of files

for f in net-acct-*; do gzip "$f"; done

unzip files create a directory to put them in

for f in *.zip; do a=`/bin/basename $f .zip`; mkdir $a; cd $a; unzip ../$f; cd ../; done

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 {} /usr/local/media/movies/

cv (strip comments from a file)

grep -vE '^\s*(#|$)' $1  | grep -v -e '^$'
misc.txt · Last modified: 2013/02/21 09:52 by paulsmith
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Noncommercial-Share Alike 4.0 International
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki