Tag Info

New answers tagged

0

ps is utility that produces human-readable output, and rely on grepping human-readable text is bad idea. You should use pgrep myShittyProcess instead of ps aux | grep myShittyProcess. pgrep produces bare list of pids, and if you want less boring output, you can pass pgrep's output to ps: ps -opid,user,args -p `pgrep myShittyProcess` To use that one-liner ...


0

This is apparently a known bug in Tcsh in the particular version of Tcsh and RedHat that I am using. Apparently there is a patched version of tcsh available for this issue, as described in this errata, for RedHat 5.4: Expansion of multiple filename globs failed if any glob in a command line expression failed. The correct behavior outlines that a glob ...


1

The following command should achieve what you want, i.e. do not output matching lines whose length is greater than 1000 characters: grep -r --color=always $pattern . | cut -c1-1000 The --color=always flag ensure that color escape sequences will be generated by grep. This option default value is --color=auto, which makes grep color its output only if it ...


-1

Finally i fount it ... this is the regex : grep -E -o -n -H "'(\w|\W)+(([[:blank:]]\w+)*|\W([[:blank:]]\w+)*)*[[:blank:]]\w+((\W)|(\w+))'" and this is shortest and powerful: grep -E -o -n -H "'(\w+|\W|\d+|[[:blank:]])*'" and this is some of outputs : forms.py:94:'remove_choices must be a list' forms.py:142:'unknown', _('select country' ...


6

If the input file is called data, one solution is: awk '{print>$1}' data In awk, the first field (column) is called $1. The above loops through each line of input (awk does this implicitly) and writes that line to a file whose name is the first field. In more detail: The command is placed in braces. Since there is no qualifier in front of the ...


3

Grep is probably working right. Your command is what's off. I answered something similar before here, regarding chown on UNIX, with a UNIX shell. Some of the explanation may be useful. If you want to check using the recursive flag, you want to pass a directory: grep -r fred . This will find fred in any files rooted at ., named *.txt or not. If you ...


0

This can be done in notepad++ when you hit ctrl+shift+F command is called Find in files. It does not accomplish the "first three lines". A workaround for that may be to name my tags @tag1 or #tag1 or &tag1 to begin with.


3

The easiest way to do this is on your GNU/Linux machine using sed(1). Assuming that only the text files you want to transform are on the directory: $ for a in /path/to/directory/*txt; do sed -i '1,3{s/tag1/tagOne/g;}' "${a}"; done What this does, explained in more detail: There is a loop to iterate over the files you want to work with: for a in [...]; ...


1

If you don't mind installing external tools, my call would be Pygments It is a generic syntax highlighter for general use in all kinds of software such as forum systems, wikis or other applications that need to prettify source code. Highlights are: a wide range of common languages and markup formats is supported special attention is paid to ...


0

grep -m 1 -o -e success -e error < <(tail -f output.log) | head -n 1 Output: success or error


1

If you're searching binary files, then you must use grep because ack will ignore them, always. When searching through a few large files, grep will be faster than ack. It sounds like you're trying to decide if you should abandon grep and use ack all the time, and I suggest that you should not. You should use both grep and ack when it's appropriate. ...


1

You should have a look at the man page and it will tell you: WHEN TO USE GREP ack-grep trumps grep as an everyday tool 99% of the time, but don't throw grep away, because there are times you'll still need it. E.g., searching through huge files looking for regexes that can be expressed with grep syntax should be quicker with grep. If your ...


0

ack is not part of default installation on all Linux/Unix server but grep is. Have you tried the_silver_searcher or the_platinum_searcher. They both run faster than ack


-1

Try that in terminal: netstat -tuonp


0

You will have to grep the disk instead of the disk slice. Using my machine as an example, $ diskutil list /dev/disk0 #: TYPE NAME SIZE IDENTIFIER 0: GUID_partition_scheme *240.1 GB disk0 1: EFI EFI 209.7 MB disk0s1 2: ...


1

You can use -A to specify how many lines after a match you want printed. grep -A 20 '`database`.`tablename`' dump.sql This will of course also include the match, and you can pipe that to a viewer. There's no need for head here.



Top 50 recent answers are included