Tag Info

Hot answers tagged

6

First, this is about a lot more than just coreutils. The BSD equivalent to GNU findutils is also quite different, pretty much every command related to dynamic linkage is different, etc. And then on top of that, you have to deal with versioning differences: OS X still ships a lot of older software to remain on GPL2 instead of GPL3, such as Bash 3.x instead ...


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

The latest version of the HFS+ utilities on Debian are, as far as I can tell, from 2006 and lacking a maintainer. Apple released Time Machine in 2007, and when they did they introduced some quite significant changes to HFS+ (particularly to do with hard links to directories). It is highly likely that the HFS+ tools on Debian cannot deal very well with a Time ...


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


3

As the API returns JSON objects, I'd use a JSON parser for it, combined with sed and grep. I've decided for jq, which is contained in the Ubuntu repo's, so it could be installed using sudo apt-get install jq; I don't know what distro you are using, so you'll have to find that by yourself if you want to use this solution. jq ".[]" <filename> | sed ...


3

...per your comment on the question... pax -rws'/\.JPG$/.CAP&/' /root/of/copied/tree /dest/path If .jpg and .JPG are your only issues, that should just work. You can also add a print primitive to the filename substitution to get a list of all of those filenames which were changed: pax -rws'/\.JPG$/.CAP&/p' /root/of/copied/tree /dest/path As ...


2

Do you mean NDP for IPv6 as defined in RFC 2461? If so, there is ndp command for OSX. To quickly get results you can run: ndp -an


2

That should do it: grep -rlZ "wrongtext" ~/Library/Calendars | xargs -0 sed -i '' 's/wrongtext/righttext/g' I added the -Z parameter to grep to add a zero byte instead of a newline after every filename. So the command works also with strange filenames. xargs then reads the input delimited by the zero byte with -0 and calls the sed command.


1

2 shots: 1. Perhaps login as root is denied (that's the default setting on many systems and it is pretty reasonable). Did you tried with a different user? 2. Did you try sshing with ssh -Y?


1

Figured it out. It does not like the -O grep -rlZ "wrongtext" ~/Library/Calendars | xargs sed -i '' 's/wrongtext/righttext/g'


1

Here's a brief stab: # for f in $( find yoursourcedirectory -name \*.jpg ) ; do cp ${f} yourtargetdirectory/${f}.CAP1.jpg ; done then # for f in $( find yoursourcedirectory -name \*.JPG ) ; do cp ${f} yourtargetdirectory/${f}.CAP2.jpg ; done This will take all the files named *.jpg in the source, and copy them over as *.CAP1.jpg and all of the *.JPG ...


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

0xC0000022L's answer is thorough for the Windows side of things. The Mac can recognize Linux's symlinks; however Linux cannot recognize aliases made in the Mac's Finder (symlinks created using ln -s work fine).


1

Homebrew also has a recipe for rpm installation, just run brew install rpm


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