Tag Info

Hot answers tagged

12

Switching the color is done through escape sequences embedded in the text. Invariably, programs issue ANSI escape sequences, because that's what virtually all terminals support nowadays. The escape sequence to switch the foreground color to red is \e[31m, where \e designates an escape character (octal 033, hexadecimal 1b, also known as ESC, ^[ and various ...


7

awk -F '","' 'BEGIN {OFS=","} { if (toupper($5) == "STRING 1") print }' file1.csv > file2.csv Output "12310","42324564756","a simple string with a , comma","string with or, without commas","string 1","USD","12","70%","08/01/2013","" "23525","74535243123","string , with commas, and - hypens and: semicolans","string with or, without commas","string ...


6

You can have grep look for control characters, some of which are responsible for making the pretty colors on the terminal. dolongtask | grep '[[:cntrl:]]' For example, this echoes a red "test" into grep, which finds it due to it being surrounded by control characters: $ echo -e '\033[00;31mtest\033[00m' | grep --color=none '[[:cntrl:]]' test <-- ...


5

Perhaps awk? awk 'BEGIN{a = "foo"}; a !~ /foo|bar/ && $0 !~ /foo|bar/{print a}; {a = $0};END{if(a !~ /foo|bar/){print a}}' InputFile


4

Try this : grep -v "$(grep -E -B1 "foo|bar" InputFile)" InputFile


3

awk '$3 >= "11:58" && $3 <= "23:58" && /Unit ID: 1111/{print l"\n"$0};{l=$0}'


2

Just type: *myfile* You can also do: "$(ls | grep pattern)" if you full regular expression matching rather than just filename wildcards. All these solutions assume there's just a single file in the current directory that matches the pattern.


1

You can use xargs for this sort of thing: ls | grep myfile | xargs sh xargs reads lines on its input and gives them as arguments to the program it's given as argument: here, it will read the output of grep and then run sh long_myfile_name. (Change sh to bash if your script depends on Bash-specific features, or some other shell) You can also run sh ...


1

The filter settings are saved as a gsettings scheme: org.gnome.gnome-system-log.filters. You can edit them with dconf-editor (org>gnome>gnome-system-log>filters). Replace the space in the name of the filter with a dash (or some other character), and gnome-system-log will work again.


1

In practice I found the following idiom enough: ps auxf | grep -v ]$ It filters lines ending with brackets, which might result omitting unwanted entries but it's very unlikely. In exchange it's quite easy to remember and relatively quick to type.


1

You can simply use | less -r >


1

This sed command did it for me: sed -r "s/\\^\\[(\\[[^@-~]+[@-~]|[0-9@-_]|%@)//g" Example: $ command-that-produces-colored-output | sed -r "s/\\^\\[(\\[[^@-~]+[@-~]|[0-9@-_]|%@)//g" > outfile



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