Tag Info

Hot answers tagged

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


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


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


3

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


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


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

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)


2

I do not know if there is a more elegant method but this works for me: mkfifo onerandom tworandom threerandom tee onerandom tworandom threerandom < /dev/urandom > /dev/null & shuf --random-source=onerandom onefile > onefile.shuf & shuf --random-source=tworandom twofile > twofile.shuf & shuf --random-source=threerandom threefile > ...


2

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


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.


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.


1

As per the comments I have confirmed this at the bottom of this answer. I think the issue is that a streaming zip will default to Zip64 format but that unzip 6 or later is needed to read Zip64. The manual says -fz- can be used if the input is known to be smaller than 4 GB to prevent the use of Zip64, but that isn't clearly documented anywhere else in that ...


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


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

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"'/'


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

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


1

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


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.


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.



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