Tag Info

Hot answers tagged

6

don's might be better in most cases, but just in case the file is really big, and you can't get sed to handle a script file that large (which can happen at around 5000+ lines of script), here it is with plain sed: sed -ne:t -e"/\n.*$match/D" \ -e'$!N;//D;/'"$match/{" \ -e"s/\n/&/$A;t" \ -e'$q;bt' -e\} \ ...


6

You could use grep with -A and -B to print exactly the parts of the file you want to exclude but add the -n switch to also print the line numbers and then format the output and pass it as a command script to sed to delete those lines: grep -n -A1 -B2 PATTERN infile | \ sed -n 's/^\([0-9]\{1,\}\).*/\1d/p' | \ sed -f - infile Another way with comm: comm ...


4

If you don't mind using vim: $ export PAT=fff A=1 B=2 $ vim -Nes "+g/${PAT}/.-${B},.+${A}d" '+w !tee' '+q!' foo aaa bbb ccc hhh iii -Nes turns on non-compatible, silent ex mode. Useful for scripting. +{command} tell vim to run {command} on the file. g/${PAT}/ - on all lines matching /fff/. This gets tricky if the pattern contains regular expression ...


1

How about (using GNU grep and bash): $ grep -vFf - file.txt < <(grep -B2 -A1 'fff' file.txt) aaa bbb ccc hhh iii Here we are finding the lines to be discarded by grep -B2 -A1 'fff' file.txt, then using this as an input file to find the desired lines discarding these.


1

diskutil list will show you the Drives. A Partition is /dev/diskXsY. So dd if=/dev/diskXsY of=/BACKUPIMAGE.img with the appropriate X and Y should do it for you.


1

Too fast diagnosis I read online that this might be resolved by repairing permission on the drive. Unfortunatly, from the description of your problem, this is wrong. What need to be repaired is the filesystem on your external disk SEAGATE. Analysis of lsof The output of your lsof command tells that the command mds (1st column) is actually reading ...


1

FileVault (and OS X in general) does not check /etc/passwd, so a script using it as a trigger will not work. FileVault uses DirectoryServices, so any interception of what is being entered has to be through Apple's OpenDirectory implementation (see documentation on DirectoryService). How to do that is beyond me, but reading up on ...


1

Quick answer: Install bash-completion Source bash_completion on Bash startup Add your compspec on Bash startup Don't overwrite sudo compspec with complete -cf sudo I suppose that you use MacOSX with brew. Try: brew update brew install bash-completion brew info bash-completion # bash-completion: stable 1.3 . $(brew --prefix)/etc/bash_completion complete ...


1

OS X supports pthread_cond_timedwait but it uses absolute calendar time and there is no way to use a monotonically increasing time.



Only top voted, non community-wiki answers of a minimum length are eligible