Tag Info

New answers tagged

3

You could just print the second line. You can use many tools for this: sed defaults read -g AppleLanguages | sed -n '2s/,//p;' file Explanation: The 2 means "run the following commands only on the second line". The -n suppresses normal output (nothing is printed unless explicitly told to do so). The substitution (s///) deletes the comma and the /p at ...


2

You can do the following: awk -F, '/[^(]/{print $1;exit}' Explanation: -F,: treat , as field separator [^(]: for lines that contain at least one non-( character. print $1; exit: print first field and immediately exit the awk (so only first line which matches the pattern will be printed)


1

This is either triggered by a mapping or an autocmd (that subsequently somehow inactivates itself). You can capture a full log of a Vim session with vim -V20vimlog. After quitting Vim, examine the vimlog log file for suspect commands. You can also list suspecting autocmds via :verbose autocmd CursorMoved.


1

These strange escape sequences are color-changing commands. The completion code runs the following command to list available commands: git help -a|egrep '^ [a-zA-Z0-9]' The output of git help -a looks like this: add grep remote add--interactive hash-object remote-ext am ...


1

If you don't need the older version of git in /usr/bin/git, the quickest and easiest thing to do is to rename the old binary in /usr/bin/git to something like git.v1.9.3 and symlink the new version. First rename: mv /usr/bin/git /usr/bin/git.v1.9.3 Next symlink new: ln -s /usr/local/git /usr/bin/git Now check the binary: git --version


5

With GNU find: find . -name foo.mp4 -printf '%h\n' With other finds, provided directory names don't contain newline characters: find . -name foo.mp4 | sed 's|/[^/]*$||' Or: find . -name foo.mp4 -exec dirname {} \; though that means running one dirname command per file. If you need to run a command on that path, you can do (standard syntax): ...


0

This allowed me to use my mac over SSH no matter what, as long as the mac is connected to a power source. Everything gets shut down when the mac gets off its power source, so you don't have to worry about battery life.


0

Doing "ls -otr --time-style=+%Y%m%d%H%M.%S" will get the date in the proper format, though with a bunch of other info that's easily edited out. This is handy when assigned to an alias, and the output redirected to a file.


2

stat -f %m -t %Y%m%d%H%M.%S myfile This prints the timestamp in the format required for touch -t. Beware that the timestamp is expressed in the local timezone, which could be awkward to port files between timezones or for timestamps during the repeated hour of the summer-to-winter switch in timezones with DST. To avoid timezone trouble, use the UTC ...


4

You may convert the time returned by stat or perl to the format you want with the command date (assuming you have GNU coreutils installed): # Convert UNIX time returned by perl to year+month+day $ date -d @$(perl -le 'print((stat shift)[9])' FILENAME) +%Y%m%d 20130703 # Convert formatted time returned by GNU stat to year+month+day $ date -d "$(stat -c %y ...


2

Well, you probably have mail. ;) It talks about your local inbox. Use mail or mutt or from to see your local mails. I'm not sure what mail client is installed per default on OSX, but I would expect to find mail on pretty much any unix system. OSX, at the end, is just another unix and unix is designed to be a multi-user system, i.e. multiple different ...


0

that'll be comsat or biff (or something like that) it's talking about the system mail spool. try the command mail it should be possible to tell the mail app to access the system mail spool, but I don't know the details.


1

Don't try to build a shell script from a list of files, it's hard to get right and almost always a lot harder than directly executing whatever you need to execute. Instead, when you have the file name available, go ahead and rename it. #!/bin/sh number=1 while IFS= read -r old_name; do new_name=$(printf %04d "$number").jpeg number=$((number+1)) mv -- ...


1

The problem is, that while the url would suggest it is a CSV, it really is not - the share volumes that contain commas are not properly quoted. That said you'll need to employ additional knowledge. In this case, try changing the format of the output from: http://download.finance.yahoo.com/d/quotes.csv?s=avxl,goog,aapl&f=snl1c6j2s6f6 producing: ...


0

Simply mount /dev/disk2s1 /foo Where /foo is an empty directory where you want to access the card. The normal mount point for disks on a mac is within /Volumes but since it isn't auto-mounting, you will need to create a directory somewhere. Don't mount it directly to /Volumes or you won't be able to access your HD, including your OS. You could mount it ...


2

If you dd'd it to your actual drive's partition, then what you're seeing on the bootloader is simply an entry for an OS that doesn't exist anymore. dd, unfortunately, does not change or replace anything except the data. It's a low level copy/replace utility with tons of features. In Mac OS X the drives are denoted as /dev/diskX where X is an integer. The ...


2

OK, you have a couple of options: The option I like best is to rename your ~/.bash_profile with AppleScript: do shell script "mv /Users/YOURLOGINNAME/.bash_profile /Users/YOURLOGINNAME/x" You could also configure Terminal to drop you straight into a root shell, so it won't ask you for the password again after the first time. In Terminal, go to ...


2

Is there any way to undo either of these two commands or to somehow access or unlock my terminal? Reboot into single-user mode: while the screen is still black as it first boots up, hold down ⌘-S. You can let go once the "Apple" screen appears. You will land in an unrestricted root shell, where you can fix things.


1

You can't modify the existing installation as non-root. But you can install a CPAN module in your home directory (or wherever you have write access) and then load that module preferentially (in most cases. It is possible for there to be conflicts between modules, but you're probably okay here). There are instructions for doing this via the cpan tool in ...


2

In Vim 7.3, the combined relativenumber-number setting you describe is not supported. See :help relativenumber, which states that: When setting this option, 'number' is reset. Vim 7.4 supports using both together, and the same section says that: The number in front of the cursor line also depends on the value of 'number', see number_relativenumber ...


2

Shell variables are set using the syntax name=value. There must not be any [unquoted] whitespace characters in the declaration. path1="./src/$1" path2="./Main/$1" # ^ remove space here The space in your usage was invoking the other usage of name=value, i.e. temporarily setting environment variables for a single program invocation. For ...


0

It is either waiting for DNS or for ICMP echo reply packets. If it's DNS, try the -n option. If it's not, try the difference between hosts that answer ICMP echo requests and those who don't (or whose answers are filtered somewhere on the way).


2

In the case where ping is outputting to a shell pipeline, the different behavior is explained by buffering. ping calls fflush() after reporting each successfully received echo packet, so those lines are sent immediately to cat, which outputs them without delay. ping does not call fflush() after writing out the lines that report timed out packets, so stdio ...


0

I believe this is because of how cat is getting the input, the first command gives an exit status of 2, whereas the IP address that is pinging gives an exit status of 0. This means that cat is displaying the output of STDOUT straight away whereas it is putting STDERR into it's buffer and then displaying it at the command termination.


0

Sum all files in a directory: OSX: find dir ! -type d -print0 | xargs -0 stat -f '%z' | awk '{sum += $1} END{print sum}' Linux: find dir ! -type d -printf "%s\n" | awk '{sum += $1} END{print sum}'



Top 50 recent answers are included