Print everything after the last occurrence
This may be long and convoluted but it is the first thing that came to mind and it worked.
Had a log file that would delimit with "As Of nn/nn/nnnn" which could be multimegabytes. Didn't feel like doing a perl solution that day, so:
grep -n 'As Of' sourcefile | tail -1 | awk -F":" '{print $1}' | xargs -r -iX awk 'FNR>=X' sourcefile > outfile
Again, likely an easier solution, but this was Q&D.
More cpio tricks
Cleaning out my desk and came across these notes…
find /mnt/old_root -depth -print | cpio -odv | gzip -c -v -1 > /opt/bad_disk/old_root.cpio.gz find -depth -print | cpio -odv > tempo.cpio cpio -idvm < tempo.cpio
Neat trick:
tar cf - . | (cd /usr/local ; tar xvf - )
Peeking on a process
We have a problem at work with an ssh failing, but I don't have access to the source of the program running ssh. So I replaced ssh with this script, renaming the old ssh to ssh_orig. The extra flags on ssh were just me seeing if I can get the thing to work, you can ignore them:
#!/bin/bash echo $* >> /tmp/ssh-$$-in ssh_orig -C -2 -x $* | tee /tmp/ssh-$$-out
This creates a bunch of files in /tmp/ with the input command line string given to the script in the -in files and the output in the -out files.
Note, this will probably cause a security audit problem since you messed with ssh.