netstat -ano
to see what process id is listening to what ports. Then cross-ref with the task manager (you can view PIDs: view->select columns, sort by PID).ddrescue -f -n /dev/in /dev/out logfile
Pull the drive and reinsert as necessary—presuming you can hot-swap—restarting with: (note that your /dev/in may change)
ddrescue -f -b -T /dev/in /dev/out logfile
And then grind on the remaining bits:
ddrescue -d -f -r3 /dev/in /dev/out logfile
lsof | cut -d ' ' -f 1 | sort | uniq -c | sort -rn | head
~ the bit I was missing in trying to figure out how to do this was the -c flag to uniq!col -bx < dosfile > newfile
[[from FreeBSD fortune file, via Dru <genesis@istar.ca>]]trafshow -f -i {interface} "not(host {myip})"
-- the "not(host {myip}) is important to keep your ssh/whatnot connection running trafshow to top out the charts. Don't know what interfaces you have? /sbin/ifconfig!ls -lR > box1
. On the other machine, ls -lR > box2
. Then get those two files together, for the following:
cat box1 | tr -s ' ' ' ' | cut -d ' ' -f 5,9 > box1.clean cat box2 | tr -s ' ' ' ' | cut -d ' ' -f 5,9 > box2.clean diff box1.clean box2.clean
tr substitutes characters of one sort for another... here, we're using a trick to compress (that's the -s) multiple spaces into a single space. Then we chop out just the important fields of the ls (5 == size, 9 == filename), and get the difference. Now, this won't catch if the files are different but have the same number of bytes. You could pass an md5 in, but that would probably take a find -exec or some such. this is just quick and relatively easy. :)
If you only want to see if the file names and directory structure are the same (don't care about file sizes) then you can leave off the "5" in the clean step, or you can run through a second clean step of cat boxn.clean | cut -d ' ' -f 2 > boxn.clean2
.
>&
2>&1
(i.e. runmydbupdate.sh 2>&1 | grep ERROR | head
...)lsof -i
shows you exactly that! You can match the pids to running processes with ps.vim `grep -m 1 -r [searchterm] . | cut -d ':' -f 1`
-- there's probably an easier way to do this, but whatever. :) "-m 1" tells grep to stop searching a file after the first match, -r is recursive, and the cut grabs just the filename from the grep results. (Piping the results through xargs) instead of (using the backticks and passing to vim directly) can cause strange artifacts, like losing the ability to pass a carriage return. Another way to do the grep that comes to mind a little easier but is the slightest bit more wasteful is grep -r [searchterm] . | cut -d ':' -f 1 | sort | uniq
. Just a thought. :) NOTE: If you're wondering why grep is "taking soooooo long", make sure you put the period after the search term. That's the path it's supposed to recurse from; else it will be parsing your stdin, instead.find . -type f -exec /usr/bin/perl -pi -e 's/find/replace/g' {} \;
-- what I've used this for a couple of times is moving an svn repository, or rather, cleaning up after doing so: find . -type f -name entries -exec /usr/bin/perl -pi -e 's#http://oldrepos/location#http://newrepos/newlocation#g' {} \;
find . -not \( -path ./includes -prune \) -not \( -path ./forum -prune \) -regex '.*/.*\(php\|html\)' -exec wc -l \{\} \; | tr -s ' ' ' ' | cut -d ' ' -f 2 | paste -sd+ - | bc
tar cspzf backup.tgz "--exclude \"*.{mp3,mpg,avi,tgz}\" *
dd if=/dev/cdrom bs=2048 count=326239 conv=notrunc,noerror > file-name.iso
cmake
make -VERBOSE=1
cmake -DCMAKE_VERBOSE_MAKEFILE=1
mysqlcheck -Aao -uroot -p
or, more verbosely? mysqlcheck -u root -p --auto-repair --check --optimize --all-databases
SELECT d.datname as "Name", u.usename as "Owner", pg_catalog.pg_encoding_to_char(d.encoding) as "Encoding" FROM pg_catalog.pg_database d LEFT JOIN pg_catalog.pg_user u ON d.datdba = u.usesysid ORDER BY 1;
select * from pg_user
. pg_group for groups.watch --interval=1 "ps ax | grep post | grep -v watch | grep -v grep | sed 's/^ .\*?//' | tr -s ' ' ' ' | cut -d ' ' -f 5-"
pg_dump -b -f filename -F c -U postgres dbname
pg_dumpall --globals -U postgres
pg_restore filename -C -d template1 -U pgsql -W
mplayer -dumpfile [dumpfile] -dumpstream [dumpstream]
mplayer -vo null -vc null -ao pcm -aofile [wav output] [dumpfile]
lame [wav output] [mp3 output]
convert -resize 320x240 10000.mov 10000_resized.mov
ffmpeg -i 10000_resized.mov -vcodec libx264 -threads 0 -b 320k -f mov -y 10000_resized_webok.mov
Voila! HTML5-ready video! sized small, and lowish-bitrate. :)
And it looks like -vf scale=320:240:-1
to ffmpeg would do the resize there (with -1 "trying to keep aspect ratio"?)