Tag Info

Hot answers tagged

13

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


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


3

You can use a regular expression: &!cat|dog|fish


3

wget includes features to support this directly: wget -r -A "*.ai,*.cdr" 'address-of-page-with-hyperlinks' -r enables recursive mode so it will download more than simply the given URL, and -A limits the files it will download and keep in the end.


2

Which Unix? It will be quite difficult to make it so that file creation fails when an "invalid" name is passed to it, but there are some platform-specific ways of doing this. First of all, there is inotify and its relatives, which can at least observe the filesystem and notify you immediately when a file is created. I'm not sure you can actually stop the ...


2

You're on the right track with sed: all you need to do is to transform your list of line numbers to be followed by a p and a newline, and use that as a sed script. For example, if you have a space-separated list: lines="2 3 5 7 11 13" <sourcefile.tsv sed -n "$(echo "$lines" | sed 's/$/p/; s/ /p\n/')" >extractedrecords.tsv Awk is another ...


2

Assuming linenumbers.txt has one number per line awk 'NR == FNR{a[$0]; next};FNR in a' linenumbers.txt sourcefile.csv > extractedrecords.tsv Might do the job. Or, with bash join -t':' -o2.1,2.2 <(sort linenumbers.txt) <(awk '{print NR":"$0}' \ sourcefile.csv | sort -k1,1 -t':') | sort -k1,1n -t':' | cut -f2- -d':' All the extra jumping ...


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 do it : rdr pass quick on $ext_inf inet proto tcp from any to any port 1394 -> $target port 1394


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

Just Do It. dummyvalue=`sleep 10` If you want it as part of a recipe, you can easily run any command synchronously: :0w * ? sleep 10 { } (I added the w flag for good measure.) Much larger values are possible, though if you exceed the default value of TIMEOUT, Procmail will abort the sleep. Though you can bump the value of TIMEOUT to a larger value ...


1

Old post, but for reference, it wouldn't work for a few reasons: The priority should be 16 and not 1 The filter handle should be 800::800 and not 800:800 You must supply the parent qdisc that the filter is attached to This should work: tc filter del dev peth1 parent 1: handle 800::800 prio 16 protocol ip u32


1

Grep the first longest line grep -Em1 "^.{$(wc -L <file.txt)}\$" file.txt The command is unusually hard to read without practise because it mixes shell- and regexp syntax. For explanation, I will use simplified pseudocode first. The lines starting with ## do not run in the shell. This simplified code uses the file name F, and leaves out quoting and ...


1

If your system has access to NodeJS you could install the following Node package, strip-ansi. $ npm install -g strip-ansi You can then run your command like so: $ command-that-produces-colored-output | strip-ansi > outfile



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