Skip to main content

All Questions

-1 votes
1 answer
54 views

awk inside function causing errors

I'm trying to add the following to my .bashrc: cpu_info() { top -b -n1 | grep Cpu(s) | awk '{print $2 + $4}' } but bash is telling me: bash: .bashrc: line 131: syntax error near unexpected token `...
Mathew's user avatar
  • 243
4 votes
4 answers
691 views

grep multiple patterns with differing number of matching groups?

I'm trying to tally insertions and deletions from git diffs. I have the following, which when piped one or more strings of the form "4 files changed, 629607 insertions(+), 123 deletions(-)" ...
jawns317's user avatar
  • 143
0 votes
4 answers
183 views

Removing trailing newline from grep output

I'm looking for way to remove new line from grep output, I use grep -oP "changed: \[([^]]+)\] =>|'path': '([^']*)'" /path/to/file The output is like: changed: [hostname1] => 'path': '/...
shlco's user avatar
  • 1
0 votes
2 answers
86 views

Trying to get a desired output from a text file

I have a output like this in a text file, where ^M represents CR Last login: Sat Jan 22 09:49:50 2023 from 10.1.1.1^M Cisco Router uptime exit -f Connecting user mike from 10.1.1.1 ******************...
rmb's user avatar
  • 871
-1 votes
3 answers
471 views

How to match end of last string in file which does not end with punctuation

I'm trying to search a directory for files which do not end in a period. I'm trying to list the file name with the final ascii character which is not followed by period/ punctuation. I've looked all ...
Doodling's user avatar
0 votes
1 answer
775 views

Return content between corresponding brackets

I have a file with all type of brackets {}[]()- nested, open and close appropriately. I would like to return the content within the matching square brackets after the string (text:). The content of ...
SKPS's user avatar
  • 13
2 votes
4 answers
1k views

grep 2 words from specific csv column and count them

I am trying to find a better way to complete the following grep/awk query. The below is a trivial example of the question. I have gotten to this point with my regex: grep -Po ^(?:[^,]+,\s?){7}(Want|...
malkier11's user avatar
1 vote
2 answers
159 views

How I can grep data with some spaces and ignoring block?

I am trying to retrieve Local Address-port with port number in different block used by each IP-address in Foreign Address and PID/Program name) from the following and store it in a file: I used: ...
Tech Parinda's user avatar
0 votes
0 answers
35 views

Filter csv file with AWK passing a variable in the regex [duplicate]

I need to filter a very large csv file in the most efficient way. I already tried csvgrep but is not efficient timewise, so I'm now trying to use AWK for this task. The csv file has a ; separator, and ...
Margherita Di Leo's user avatar
0 votes
2 answers
680 views

Match a pattern and replace the value of the following key value pair

I'm trying to modify a file that contains sections like this: [ policy_strict ] countryName = match stateOrProvinceName = match organizationName = match organizationalUnitName =...
Allan M's user avatar
-1 votes
1 answer
88 views

Select a particular portion from a html dump using regex based on a criteria using Unix commands

I am stuck with a question where I am supposed to display only those commands with a number of votes >= 1 from a dump of page http://www.commandlinefu.com using Unix commands. I am attaching a ...
rafaelx12's user avatar
0 votes
1 answer
453 views

Print text that appears after a substring match using awk in Perl

I have a multiple strings, as shown below, in a file MyFile- 1234|5|678|ABC|d|e| MyString - values: foo 1, bar 10%, baz 2/2, qux quux 10 sec, quuz 10km How to print the substrings 1234 10 sec based on ...
Ira's user avatar
  • 105
0 votes
2 answers
2k views

Searching for text patterns in a log file

I have a large log file where all the lines contained are of similar format. They can vary a bit, but the format until the first ] bracket is always exactly the same. 31.7.112.60 - - [26/Jan/2019:19:...
user140161's user avatar
1 vote
4 answers
1k views

Remove comments from file while ignoring quoted comment signs

I would like to remove comments starting with # from a file. I have tried the simpler approaches described in How can I remove all comments from a file? but I have a few additional rules: A # does ...
Martin Konrad's user avatar
0 votes
1 answer
48 views

test all line in a file with awk and grep and if it match put them in an other file

Here is my file test.csv bonjour|b|french;deutsch|french hello|h|english;russian|french gutentag|g|german;polish|french ciao|i|italian|french I would like to test if the third split by | is french (...
Bussiere's user avatar

15 30 50 per page
1
2 3 4 5 6