Tag Info

Hot answers tagged

20

You either have trailing whitespace, or a corrupt filesystem. Try for i in tftp.plist* do echo "'$i'" done That should output something like 'tftp.plist' 'tftp.plist ' note the quotes and the extra space. If it outputs the exact same thing twice, you likely have a corrupt filesystem. Try ls -i tftp.plist* this will give you the inode numbers ...


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 ...


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\} \ ...


5

On OS/X, like on all systems where they are supported except Linux, opening /dev/fd/x is like doing a dup(x), the resulting fd more or less points to the same open file description as on fd x and in particular will have the same offset within the file. Linux is the exception here. On Linux, /dev/fd/x is a symlink to /proc/self/fd/x and /proc/self/fd/x is a ...


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 ...


4

Actually your resolved command isn't right. It's really this: ssh -i "~/Keypairs/jadam-macbookpro-ec2-1.pem" "ec2-user@12.3.4.567" The double quotes stop the shell expanding ~ and it's treated as a literal. Replace it with the environment variable $HOME and the problem will resolve itself: KEYPAIR="$HOME/Keypairs/jadam-macbookpro-ec2-1.pem" sudo ssh -i ...


3

You could do: find . -name '*.png' | awk -F/ '{print tolower($NF)}' | sort -u > ~/tmp/png-files && grep -IhFriof ~/tmp/png-files --exclude-dir=".svn" . | awk '{print tolower($0)}' | sort -u | comm -23 ~/tmp/png-files - That would give you the lower-case names of the png files that are never referenced. The first pipeline builds a sorted ...


2

Your second problem seems to be an issue with tmux and the evaluation of certain AppleScripts through osascript. There's a wrapper you can install which should fix the problem. You'll want to install reattach-to-user-namespace through Homebrew or MacPorts and wrap the call to osascript: reattach-to-user-namespace osascript -e 'display notification "Hello, ...


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

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

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

If you think the problem might be an idle connection getting closed, you might be able to work around the problem by using a --timeout option (newer rsyncs send keep-alive messages during lulls). You can also configure ssh to send keep-alive messages when using Protocol 2 (look for KeepAlive, ServerAliveInterval, ClientAliveInterval, ServerAliveCountMax, and ...


1

Use git fetch --quiet. In order to implement progress meter git uses setitimer() which in turn causes frequent SIGALRMs to be delivered. sshfs doesn't handle them very well, causing either Interrupted system call or File exists errors depending on the timing and command. The problem is timing-dependent and gets worse with larger repositories.


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