Tag Info

New answers tagged

2

OS X is a certified UNIX operating system, guaranteeing it implements the POSIX standard. Linux, while not a certified UNIX, also implements the POSIX standard. If you limit your API calls to things that are part of POSIX you should have consistent behavior between OS X and Linux. Aside from POSIX, the C standard library is also standardized and you ...


5

I would say that it is misleading to call getpid() a "linux system call". That gives the impression that it is a Linux-specific system call, which it isn't. Actually, getpid() and many other system calls are specified by POSIX, and you will find it implemented on both Linux and MacOS and on many other systems, with identical behaviour. The majority of ...


0

Posting here since How to check progress when using dd ? was closed as a duplicate... With gnu dd, as of coreutils v. 8.24, the status operand supports a new LEVEL of information: progress. When used with status=progress, dd will print data transfer statistics on stderr approximately every second. status=LEVEL The LEVEL of information to print to ...


2

Use this: security find-certificate -c "certificatename" -a -Z | \ sudo awk '/SHA-1/{system("security delete-certificate -Z "$NF)}' awk is called with sudo. awk then searches for the string SHA-1 and calls the security delete-certificate command with the hash as argument. You have to provide the sudo password only once.


1

Some shells, including bash, allow you to type any literal character (e.g. Ctrl-I for Tab, Ctrl-M for Return) by prefixing it with Ctrl-V, so you could type Ctrl-V Ctrl-I instead of \t wherever it appears in your sed one-liner.


0

You should find the newly installed vim in the bin directory under the homebrew prefix: echo `brew --prefix`/bin/vim Certainly brew info vim will tell you what cellar brew installed vim into. Since I haven't installed vim using homebrew, let me show you an example using wget: benlavery@Talantinc:~ $>brew info wget wget: stable 1.16.3, HEAD Internet ...


0

Maybe a simple: $ ls --color=always | od -cAn will be enough.


3

For ls you can do export CLICOLOR_FORCE=X ls -G | cat -vet


4

Use script /tmp/output to start recording in a new shell, then type your commands and look in the /tmp/output file, e.g. with an editor or cat -vet. Type exit to the shell to exit the recording.


3

Probably best to run the output through a hex viewer (e.g. od, hexdump, xxd): % man less | hexdump -C | head -5 00000000 4c 45 53 53 28 31 29 20 20 20 20 20 20 20 20 20 |LESS(1) | 00000010 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | * 00000040 20 20 20 20 20 20 20 4c 45 53 53 28 31 29 0a 0a | LESS(1)..| 00000050 ...


4

Most core utilities behave differently when they output to an interactive terminal. If they detect you are outputting into a file or a pipe, they don't format (reasonably so: we don't want color escape sequences when we are processing file lists with a script). For ls, you can force it: CLICOLOR_FORCE=1 ls -G (That's for OSX; on Linux, that would be ls ...


0

It could be a Graphics Processor issue. A couple things to try are... Turn off Automatic Graphics Switching in Preferences > Energy Saver. That has fixed some dual monitor problems for me. Or, when its happening Go to Utilities > Activity Monitor make sure Graphics Card is checked in View > Columns > Graphics Card ( the column title is 'Requires High Perf ...


1

You might want to use rvim or vim -Z to avoid the trivial root shell escape. Personally I'd write a short script that allowed the user to edit just the necessary files. Then, if any changes were detected it could offer to restart the Apache server, too. The script could even make automatic backups.


0

When running the Terminal app, choose Terminal > Preferences... This will bring up an options menu. Under Settings there's a tab for the keyboard. The checkbox "Use option as a meta key" makes the Alt/Option key work like you expected (I tried it in Emacs and it worked).


4

Means folk can leverage this to get a root shell, thereby bypassing your security, eg :!/bin/sh from within vim. Or :r /etc/shadow and :w /etc/shadow. And so on...


0

If the newly installed vim is your current vim: echo `which vim` If you want to override system vim with brew: brew install macvim --override-system-vim If you want to play with paths in a script, I'd recommend reading this q/a: http://stackoverflow.com/questions/21694327/installing-vim-with-homebrew


1

As @St├ęphaneChazelas mentions, you can use pgrep - from the man page: The pgrep command searches the process table on the running system and prints the process IDs of all processes that match the criteria given on the command line. SERVICE='Google Chrome' if pgrep -xq -- "${SERVICE}"; then echo running else echo not running fi


0

You need to quote "$SERVICE": SERVICE='Google Chrome' if ps ax | grep -v grep | grep "${SERVICE}" &> /dev/null; then echo running else echo not running fi


1

If you need to use more expressive grep-style file patterns: tar -OT <(tar -tf /path/to/file.tar | grep 'FILE_PATTERN') -xf /path/to/file.tar \ | grep 'CONTENT_PATTERN' -O specifies the output to be stdout, and -T specifies a file containing names to extract, when used in conjunction with -x. If simpler pathname expansion is good enough, you can ...


1

You should try GooBook, it supports oauth2 and also has a query command which prints what you've searched to stdout $ goobook query foo foo@bar.com Joe 'Foo' Smith Group Name It also creates a cache file with I don't know which format which dumps all the address book in a one place whenever you want. It's probably worth adding that goobook ...


-1

From the command line you can use the tar command.


1

The following prints the current date with a reversed field which is replaced in cal by sed. ptd=$(date -j +%d) ctd=$(printf "\033[0;7m"$ptd"\033[0m") cal | sed 's/'"$ptd"'/'"$ctd"'/'


2

I've tried ubuntu, fedora, slackware, and netBSD and all the cal's automatically highlight the current day. However, I know some cals don't auto highlight, and either way, this does work: cal | grep -C 6 --color -e " $(date +%e)" -e "^$(date +%e)" Although I can't test on OS X as I do not have access to it.


2

Increase your virtual hard disk space to 12 GB or more. I faced similar issue and the above resolved my issue.


0

The Apple Open Directory is a fork of OpenLDAP plus Kerberos with some extra Apple sauce thrown in. Fields would thus likely be typical LDAP entries; I'd have to dig around to see where and how they are hiding anything Kerberos related. The interface would be via anything Apple-specific (e.g. see API docs under Xcode) or via the standard unix interfaces ...


1

The access time on a directory is rarely useful. The first time you run ls or find in the directory, its access time is updated. You could simply look for files that haven't been accessed in a long time: find . -type f -atime +999 -print If you're only interested in directories where none of the files have been accessed in a long time, you can combine a ...


0

Different commands support different option styles. The major trends are: getopt(): getopt() is a 30 year old programming API to parse options. It's widely available and the only POSIX standard. It only supports single letter options some of which can take arguments. Several options can be combined together for brevity. Example: tail -fn -2: an ...


1

find /some/where -type d \( -atime +1234 -o -mtime +1234 \) -print | ...


0

I couldn't figure it out with sed probably because it's not good for multi-line stuff. Not sure where you got that from... There's already a sed answer that works with your first sample file. For the second one you could try: sed '/^click$/{N;N;G;s/\n\(.*\)\n/(\1)/;s/\n/,/}' infile Though none of the above will work with unknown input and variable ...


0

For GNU sed sed -Ez 's/(click)\n([^\n]*)/\1(\2)/g' or old-style sed '/click/{N;s/\n/(/;s/$/)/;}'


2

With awk: awk '{if($0=="click"){getline n;printf "%s(%s)\n", $0, n}else{print}}' file If the line matches click, load the next line in a varable called n and then print the desired output format. Edit: If there is a variable number of multiple lines and you want to combine them until the empty line occures, use this: awk '{if($0=="click"){getline n; ...


0

perl is good tool for this job: $ perl -p00e 's/click\n(.*)\n/click(\1)\n/' file click(css_add_violation_false) click(css_add_claim_false)


1

The problem started when I installed Homebrew's version of python rather than the Apple version. The error was resolved by running brew uninstall python I discovered this was the solution by reading about a similar error produced by another Python program on OS X.


0

Neither of the commands in the first answer had the desired effect but based on those, I experimented with the following: has open, flag f = open "$@" Now, a rifle.conf file comprising just that one line does seem to be effective. If I understand correctly, the one and only condition, satisfied, is that open is installed (i.e. located in $PATH). Google ...


0

What have you tried so far? According to one of the ref links you posted, the line: has open, flag f = open -a "$1" or has open, flag f = "open -a" "$1" would be where I would start. I'm unable to test, not having access to OS X.


0

The headers in /usr/include/linux are provided by the Linux kernel. As noted in that projects README file the code depends on the "taskstats API", which is specific to the Linux kernel, I don't believe you'll get this running unmodified on OSX.


1

Your issue is the -f option. Instead of specifying the file to search, -f specifies a file to read a list of patterns from. OS X grep's man page explains it, though not very clearly: -f file, --file=file Read one or more newline separated patterns from file. Empty pattern lines match every input line. Newlines are not considered part of ...


1

I am stupid... The problem was the exports. I forgot that I moved the definition of /usr/local/bin in PATH to ~/.exports from /etc/paths. All I had to do was source the ~/.exports first in ~/.bash_profile. The ls color problem was from GNU core utilities that I installed via homebrew. Apparently it doesn't support the G flag, like os x's ls does.


0

You should have .bash_profile and .bashrc at least and may have .profile, .bash_aliases, .bash_logout and many, many other files in your home directory that affect bash. The exact structure of such files changes with the OS and personalization by the user. For a full answer you need to provide the full output of ls ~/.bash* and if ~/.profile or ...


0

I've solved this in a better way than my other answer: First of all get the new vim with brew install vim and then do vim --version Make sure it is 7.4+ Note that if you do vi --version you may that vi is at 7.3 Now make vi use that newer vim alias vi=vim and add that alias to your .bash_aliases file (or wherever you put aliases) Finally add ...


0

This alternative option using a : command worked for me: :1,$!pbcopy This is useful for referring to line numbers, etc without having to navigate and highlight the area.


2

I'm sure this is a duplicate but: gg"*yG gg go to the first line "*y start a yank to the system clipboard "register" G move to the end of the file (you will see how many lines were yanked)


0

Shell Session Limit The limits set via ulimit only affects processes created by the current shell session. The "soft limit" is the actual limit that is used. It could be set, as far as it is not greater than the "hard limit". The "hard limit" could also be set, but only to a value less than the current one, and only to a value not less than the "soft ...



Top 50 recent answers are included