Tag Info

Hot answers tagged

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


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

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


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


2

Consider this thought experiment: if ps ran to completion before invoking grep as you think it should, that would mean that the shell would need to: Invoke ps. Buffer all of its output (because it has nowhere else to go yet). Invoke grep. Feed the saved output to grep's stdin. This is wasteful; it's a more efficient use of memory to invoke grep first, ...


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.


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


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


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


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


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



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