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
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
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
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
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
2 votes
4 answers
637 views

Count lines ending in "*"

I have several files in a directory with this kind of content: Wood * Nails Large Hammer * Some names have a star after them, some don't. I have multiple files with such content. In each file a ...
math101's user avatar
  • 51
1 vote
1 answer
231 views

command for multiple input and multiple output

I am performing some operations using the grep, sed, and cut commands on a Linux machinete: zgrep -A1 "^module" *.v.gz | sed -n -e 's/^\(module \)*\(.*(.*)\).*$/\2/p' | cut -f1 -d"(&...
Santhosh Nayak D.'s user avatar
1 vote
5 answers
6k views

Print ONLY the next line after a match with awk

I have a command that prints the line directly after a match with several pipes using different tools like grep, awk, and tail. This works but it feels somewhat messy and uses multiple pipes to ...
AndG's user avatar
  • 303
7 votes
4 answers
1k views

How to use sed, grep, or awk to keep certain lines in a file depending on line numbers in another file

I have two files. File1 contains some sentences, and File2 contains the line numbers I want to keep in File1. For example, File1: He is a boy. She is a cook. Okay. She went to school. She is pretty. ...
M.A.G's user avatar
  • 271
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
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
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
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
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
-1 votes
3 answers
320 views

Need to format text file and update based of key value format

I have a file having the below values: cat data.txt server1: calv server2: anot log: /u/log/1 server3: calv server4: anot server5: secd server6: calv LIB_TRGT_calv,anot: /tmp/hello.txt LIB_TRGT_secd: /...
Ashar's user avatar
  • 511

15 30 50 per page
1
2 3 4 5
23