Skip to main content

All Questions

Tagged with
0 votes
1 answer
120 views

Find the highest number after specific string from mutiple files

Each file has similar content: number 1: asdfa11sdfsadf number 2: asdfa12sdfsadf number 1: asdfa1sdfsadf number 3: asdfa33sdfsadf return 3 or number 3: are equally good. Have tried: max="$( awk ...
Maxfield's user avatar
  • 161
2 votes
4 answers
2k views

Grep excluding line that ends in 0, but not 10, 100 etc

I have a file that has this pattern in Linux and Unix environments. # file1 text1 98432230 text2 123412 text3 10 line4 0 line5 0 line6 40000 ... ... line10 ...
Intnox's user avatar
  • 23
3 votes
2 answers
119 views

Extract lines multiple times from a text file according to a list with repeated patterns

I have a file where each line starts with a unique identifier, for example: $ cat source.txt aaa text bbb text ccc text ddd text eee text I am trying to use fgrep with the option -f to save lines ...
6april's user avatar
  • 33
2 votes
2 answers
1k views

How to grep on a single column using a list of words

I would like to extract some rows from a file based on their match on a single column with a list of words. In awk, I could use something like this: awk '$5 == "someword" {print}' file.txt ...
Eric González's user avatar
0 votes
4 answers
104 views

Grep line containing a word OR has length in a specific range?

1598427@931 PDD 220624P00051000 ohlc=0,0,0,0 vol=0 oi=424 nbbo=69@2316/113@532 nbbo2=69@145/113@95 PDD 220617C00051000 ohlc=0,0,0,0 vol=0 oi=434 nbbo=530@1921/710@1496 nbbo2=530@31/710@115 PDD ...
Huy Le's user avatar
  • 103
5 votes
5 answers
8k views

Finding the line number of first occurrence of a text in bash script

I need to find out what is the line number of first occurrence of a given search string that should be in the start of a line in a text file and store it in a variable in my bash script. For example I ...
DEKKER's user avatar
  • 968
0 votes
6 answers
530 views

awk, sed, or grep command to output boolean file for each word in file1 to check if it's existent or not in file2

I have two files, if the word in file 1 is not existent in file 2, I want to generate the word false in the corresponding line in a new file say file 3. Otherwise, I want to output true in the ...
M.A.G's user avatar
  • 271
-3 votes
1 answer
69 views

Grep the count of an outlier for location

I am trying to find the location of an outlier based on the count of the string. For instance, if I have a list of numbers between a range of 1-100 and one of the numbers is 200, if want the grep to ...
Ethan Phillips's user avatar
1 vote
4 answers
923 views

How can I get the lsblk-devices that are NOT in use

root@pve-virt-01:~# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 250G 0 disk ├─sda1 8:1 0 1007K 0 part ├─sda2 8:2 ...
jsterr's user avatar
  • 1,341
2 votes
1 answer
439 views

How to find keywords in multiple files which often appear together?

I want to find keywords, which often occur in relation to each other. Example A directory contains markdown files, each with some keywords on the last line: $ tail -n 1 file1.md #doctor #donkey #...
Luca Etienne Schulz's user avatar
0 votes
1 answer
74 views

Timestamp on certain terminal output

I have a C++ file that outputs some terminal commands. I have the bash script to add a timestamp (ts) to each line but I wanted to know if it is possible to only add a timestamp to specific terminal ...
Tethys's user avatar
  • 9
2 votes
2 answers
230 views

Extract identifiers and corresponding brackets among overlapped brackets

I have some files contained identifiers as below: B#205918 A#273075 E#554065 Eg. sample of file1: ((((A#273075,A#273116),((A#224325,A#192952),A#243232)),(((E#7955,E#7165),E#6239),E#4530)),(((((E#3075,...
web's user avatar
  • 193
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
0 votes
3 answers
111 views

How to add column based in the second line match using SED or another command?

I have the following lines result from zcat command 1 - URL Template: https://www.test.com 2 - Response: <200 OK,{Server=[nginx], Date=[Wed, 11 May 2022 01:05:06 GMT], Content-Type=[text/html; ...
user13737800's user avatar
1 vote
2 answers
267 views

Extract field and number of occurrences per line

I have this file: John Green', 'Age: 32', 'State: New York', 'Total cars: 2', 'Manufacter: General Motor', 'Model: Pontiac', 'Year: 2000', 'Manufacter: Ford Motor', 'Model: Endeavour', 'Year: 2010 ...
Emilio Galarraga's user avatar

15 30 50 per page
1
3 4
5
6 7
73