Skip to main content

All Questions

Tagged with
1 vote
2 answers
58 views

Need to make multiple multiline replacements in file

I have a file with multiple "paragraphs" like this: <type>TRANS</type> <attributes/> <specification_method>rep_name</specification_method> <trans_object_id/&...
Todd Porter's user avatar
-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
0 votes
0 answers
71 views

Text processing grep and awk together on live script not working

I am using ssh to login to a remote server (Ubuntu), and then issue a command which outputs text/value each sec (live script). In the live output, I want to filter out the lines containing '...
SAM's user avatar
  • 1
-3 votes
4 answers
109 views

How to catch all lines of a repeating pattern and do some actions with the subresults

I am looking for a possibility to catch in a repeating text pattern all variable amount of lines between them and then do an action with it in bash. Example text: Total: text1 text2 Total: text3 Total:...
André Letterer's user avatar
2 votes
2 answers
63 views

Listing a certain part of filenames and their contents

I have a Linux machine with BusyBox, which has a directory called /data/var/lib/connman.  That directory holds some directories that I'm not interested in.  But it contains many .config files that ...
Norbert's user avatar
  • 121
0 votes
5 answers
160 views

How to add content to a file before the last } character using Busybox utilities?

There is a file with contents { "first_name": "John", "last_name": "Smith", "is_alive": true, "age": 27, "address": { ...
Maxim's user avatar
  • 119
1 vote
3 answers
122 views

print a text block / lines between pattern using grep or awk

My file file.txt looks like this: [NamesA] Andreas Alex [NamesB] Bernd Bruno [NamesC] Casper [NamesD] Doris I would like accomplish the following 3 different outputs, using grep or awk to use it ...
AKSNET's user avatar
  • 13
0 votes
5 answers
383 views

print characters between a specific pattern containing <>

i am asking for your help please. I reviewed a lot of sources and did some testing with awk and sed, but i can't get it to work. Below is a snippet of a config file which i could get an output via ...
AKSNET's user avatar
  • 13
1 vote
7 answers
313 views

Find all lines between two patterns, EXCLUSIVE of the second pattern?

Consider that I have the file listed below. I need to select all lines from every instance of the regex pattern Word A to before the regex pattern Word D. Word A Word B Word C Word D Word E Word F ...
RonJohn's user avatar
  • 1,144
-1 votes
2 answers
136 views

Grep a log file for SQL queries and their execution time

I have an application log file that also captures the execution time for each executed SQL statement, like below:- Sample logs: I 2023-11-15 07:18:00.743Z 1760463 37 ZVRwqItu6aw-b8eejMLI_gAAAAU 1@...
Arpit Jain's user avatar
-1 votes
2 answers
270 views

Filtering out values in a column that are zero

I have the following dataset: 071,36,035,08422,46217,00000,1,A,Broadalbin village (pt.),New York,18,46,46,46,45,45,44,46,44,46,43,43 071,36,045,29322,56209,00000,1,A,Glen Park village (pt.),New York,...
Mathew's user avatar
  • 243
1 vote
2 answers
197 views

Recursive pattern search - output formating: for each match file print out the specific file name "\n", line number, sentence matched "\n" in colors

I want a file content search command, under Linux so that: it will search on specified files, e.g: md, txt, htm. recursively from the folder and its subfolders, e.g: . the content search can be ...
user2718593's user avatar
3 votes
3 answers
110 views

How to recreate grep -f with awk

I have a large file with lots of unnecesarry info. I am only interested in section between edit and next and handle them as one entry. I manage to filter it down like this.... ' awk 'BEGIN {FS = &...
peti27's user avatar
  • 51
0 votes
4 answers
189 views

How to view a log file that's worth 10GB+?

The ways that I've thought of: If you get to reproduce the scenario in real time. Use tail -f application.log | tee /tmp/tailed_log But it's not sure that we'll get to reproduce the scenario in real ...
achhainsan's user avatar
2 votes
5 answers
584 views

Grep Multiple Pattern located in different lines and print in the same line

I'm trying to find a way to grep information in the file that located in the different lines and one of the pattern is contain pattern of date and time. below is the input unwantedtext unwantedtext ...
Ajie Pahlevi's user avatar
0 votes
3 answers
327 views

How do I use grep, awk, or sed to get a substring of a line up until a string literal?

I am trying to process a text file and omit a certain string literal if it occurs at the end of the line. E.g.: Source: ABC 123 DEF, characters I don't want GHI, these characters are ok Desired ...
Evan Harmon's user avatar
2 votes
2 answers
309 views

Why does awk concatenate strings from different lines

Good day. I'm trying to run a ping6 on IPv6 addresses pulled from /etc/resolv.conf.dnsph. It seems though, as if awk is stringing the IPv6 addresses onto one line. $ grep ^nameserver /etc/resolv.conf....
Bjoern's user avatar
  • 31
2 votes
2 answers
133 views

How can I select only successful values from leakcheck output?

I have these results that came from leakcheck. How do I properly exclude "false" results and still include the email using bash [email protected] {"success":false,"error":&...
noobwithskillissue's user avatar
3 votes
3 answers
730 views

Find files matching one pattern, but not another, using grep, awk or sed [duplicate]

I need to locate .php and .pl files that do not contain one string (e.g. aaa), but do contain another (e.g. bbb). I'm currently using this command: find /path/ \( -iname '*.php*' -or -name '*.pl*' \) -...
Krackout's user avatar
  • 2,742
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
2 votes
3 answers
214 views

Replace the last half in every line of a file with corresponding part in another file

I have two files A and B. Every line in both files is considered an item. The format of every item is fixed, consisting of a key and description, separated by a space. as shown in the example below. ...
echo's user avatar
  • 31
0 votes
3 answers
89 views

grep from a specific value to specific value

For example, I have a file with data: [2023-03-21 12:27:19 +0000] some_data [2023-03-21 12:27:19 +0000] some_data [2023-03-22 12:27:19 +0000] some_data [2023-03-23 12:27:19 +0000] some_data [2023-03-...
Mexanizm456's user avatar
3 votes
2 answers
760 views

How do you get the individual outputs of grep?

I've seen grep thrown around in plenty of answers but never wrapped my head around it. Now that I am playing with trying to get the content within HTML tags of a locally saved page from the internet, ...
Tim50001's user avatar
-2 votes
2 answers
91 views

Select all the text or characters between 2 text patterns that are repeating

Following is the sample .log file (there can be more lines in this) 2022 User abc (iii) 2023 defaa <party> ttt 2222221 User def (bbb) 20222 defaa <accoun> ttt 2222 User dddd (aaa) 3333 ...
John Doh's user avatar
3 votes
2 answers
396 views

Extract first word from txt file before ending with "/" sign in linux which contains "db" word in txt line

I have abc.txt file which contains two lines. I want to extract first word in line which contains db word in particular line. abc.txt: XYZ/db_abc.sql ijkl/tables/table_name/tl_abc.sql When I tried ...
Divyank's user avatar
  • 147
0 votes
1 answer
86 views

"grep -A" but with some lines removed

The problem The output of grep -A 4 davidson file.txt gives me: davidson 0 27 |r|= 0.00244 e= [-0.04073962 0.42777949 0.44157777 0.45997235 0.45997235 0.51613738 0.55005554 0.5538866 0....
Nike Dattani's user avatar
0 votes
0 answers
48 views

Script to find pdf files based on IDs

I have 500 IDs for students in an excel file (I have only one column for IDs) and I need to find the reports (pdf files) for each student among the 2K pdf files. These files are in one folder. Finally,...
Joman's user avatar
  • 1
0 votes
6 answers
224 views

search pattern and print in same line

I have a big .txt file in below format Pin name="AR_OP" status="f" Pref x=997.6800 y=2327.0400 side=N width=0.0400 depth=0.3750 / Layer id=1 -- Pin name="...
Shreya's user avatar
  • 139
0 votes
5 answers
158 views

How to bring the next line to the end of the first line using awk, separated by a comma?

I have downloaded some sequences from a publicly available database in .fa format. I want to generate a .csv file that contains the name of the sequence, and its length, separated by a comma. This is ...
Hrishikesh Hardikar's user avatar

15 30 50 per page
1
2 3 4 5
37