Tag Info

Hot answers tagged

14

Using GNU grep for the colouring: color() { GREP_COLOR=$1 grep --color '.*'; } (tail -qf /var/log/syslog | color 31 & tail -qf /var/log/fail2ban.log | color 32 & tail -qf /var/log/nginx/error.log | color 33) Note that the first 2 are started in background. That means they won't be killed if you press Ctrl-C (shell explicitly ignore SIGINT for ...


4

!-2 More fun is available. Say you want to keep operating on a file (as above, where you're using test.py, repeatedly): cp foo.py thing.py edit $_ python $_ !-2 ^thing^foo Copy an existing file to thing.py Edit (vim, emacs - though why you'd be using a command line if you were running Emacs-OS, I have no idea) thing.py - the last word in the previous ...


4

You can use !-2: $ echo foo foo $ echo bar bar $ !-2 echo foo foo That may not help with your right-hand situation. You can also use !string history searching for this sort of case: $ python test.py $ vim test.py $ !py python test.py # Printed, then run This may be more convenient to use. It will run: the most recent command preceding the current ...


4

Someting like this worked for me: (tail -f /var/log/syslog | awk -W interactive '{printf "\033[1;31m%s\033[0m\n", $0}' & \ tail -f /var/log/auth.log | awk -W interactive '{printf "\033[1;32m%s\033[0m\n", $0}' & \ tail -f /var/log/Xorg.0.log | awk -W interactive '{printf "\033[1;34m%s\033[0m\n", $0}') Explanation: tail -f file: append data as ...


2

Options for compgen command are the same as complete, except -p and -r. From compgen man page: compgen compgen [option] [word] Generate possible completion matches for word according to the options, which may be any option accepted by the complete builtin with the exception of -p and -r, and write the matches to the standard output For options ...


2

tac LCSoap_8.log | sed -n ' /Server returned HTTP response code: 500 for URL:/,/qualified-src-dn=.*src-dn/!d s/.*qualified-src-dn=\(.*\)src-dn.*/\1/p' or to reuse your grep: tac LCSoap_8.log | sed ' /Server returned HTTP response code: 500 for URL:/,/qualified-src-dn=.*src-dn/!d' | grep -Po '(?<=qualified-src-dn=).*(?=src-dn)' sed '/A/,B/!d' ...


2

You can use less with Wolfgang Friebel's lesspipe script: less file.zip:sub_file.zip


2

With find and file: find Music/Albert\ Ayler/Vibrations/ -name "*.flac" -exec file {} \; Music/Albert Ayler/Vibrations/1.Ghosts.flac: FLAC audio bitstream data, 16 bit, stereo, 44.1 kHz, 5653620 samples Music/Albert Ayler/Vibrations/4.Ghosts (2).flac: FLAC audio bitstream data, 16 bit, stereo, 44.1 kHz, 21096264 samples Music/Albert Ayler/Vibrations/3.Holy ...


1

unzip -l file.zip/sub_file.zip doesn't work because file.zip isn't a directory: it's a regular file that happens to be in an archive format. But you can create a directory that mirrors the content of the zip file, by mounting a filesystem that presents a view of the content of the zip file. There are several choices, pick whichever is easiest to install on ...


1

With zsh: $ unzip -l a.zip.zip Archive: a.zip.zip Length Date Time Name --------- ---------- ----- ---- 195 2014-08-18 09:38 a.zip --------- ------- 195 1 file $ unzip -l =(unzip -p a.zip.zip a.zip) Archive: /tmp/zsh0i0JyZ Length Date Time Name --------- ---------- ----- ...


1

Here is a possible PCRE-based solution based on a similar question Search a pattern and print preceding lines starting with another pattern grep -zPo '.*abc.*(?=(?s)(?(?!abc).)*?xyz)' file will output the last line containing abc that occurs before each instance of xyz e.g. given a file 1 abc 2 abc 3 abc 4 abc 5 abc 6 bcd 7 cde 8 def 9 xyz 10 xyz then ...


1

LESS uses several environment variables to control colors based on termcap library. The list of variable is the following: export LESS_TERMCAP_mb=$'\E[6m' # begin blinking export LESS_TERMCAP_md=$'\E[34m' # begin bold export LESS_TERMCAP_us=$'\E[4;32m' # begin underline export LESS_TERMCAP_so=$'\E[1;33;41m' # begin standout-mode - ...



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