Linux
I sometimes have to transfer files with spaces in the names, I like using a for loop, but the usual way doesn't work.
Usual way:
for file in `find . -type f|grep .ext$` do /do/something/to $file done
To get around this I use a while loop with a read instead. Using the read will read to the end of the line, enclosing within quotes escapes the spaces.
Unusual way:
find . -type f|grep .ext$ |while read file do /do/something/to "$file" done
Or if you don't like using…
There is a patch in the recent eject that…
In /etc/fstab:
/dev/sdb1 /media/usbdisk vfat utf8,user,noauto 0 0
I put in noauto because the filesystem will be mounted by root otherwise. I prefer to use the automounter (autofs) for this drive, so…
You wish to backup a directory on machine A by making a copy on machine B. (In our case, machine B is a netapp, so we get further backup for free).
On machine A, create a new key using ssh-keygen
[user@A]: cd; cd .ssh
[user@A]: ssh-keygen -t dsa -C 'rsync@A' -f rsync_dsa
Generating public/private dsa key pair.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in rsync_dsa.
Your public key has been saved in rsync_dsa.pub.
The…
- Permissions
The permissions shown are the maximum, you could put less…authorized_keys and authorized_keys2 600 .ssh 700 Home Directory 711 Keys (id_dsa,id_rsa) 600 Public Keys (id_dsa.pub,id_rsa.pub) 644
Note: this is super old, use puppet instead these days...
Script: update_machine update_file
We use this simple script (no error checking as usual) to update our machine configuration.
We keep the configuration files in cvs and download them to a new machine.
Usage: update_machine directory root
- directory
- subdirectory to apply
- root
- where to apply the files (filesystem root, useful when doing this at…
Script: iptohex
No error checking, just a simple time saver. Converts an ipaddress into hexadecimal suitable for use by tftp tools and pxe booting. The builtin command gethostip does this also, I include the script incase someone finds it useful.
Example:
uphill@surrey[1]:
iptohex 10.168.192.134
0AA8C086
#!/bin/bash
IPADDR=$1
if [ x${IPADDR}x = xx ]; then
echo "usage: $0
exit 1
fi
for octet in `echo $IPADDR |tr…
ffmpeg-20060306…
Say you have some files named a100 to a200 that you want to rename to b200 to b100 (it really does happen).
y=200 for x in `seq 100 200` do mv a$x b$((y--)) done
seq is a fairly useful tool, it can also take a reversed list.
for x in `seq 200 -1 100` do printf "$x " done