All Questions
33 questions
2
votes
3
answers
86
views
Printing a specific section everytime search results are matched
I have a pretty basic text file on a Linux machine that has stuff like Chapters, Dialogues and References.
This is what it looks like
Chapter: 1 One: Birds and Trees
Birds are beautiful and trees ...
2
votes
5
answers
331
views
Extract lines from indented output
I'd like to parse parses the output below (from ddcutil) in a shell command:
Model: MQ780
MCCS version: 2.1
Commands:
Op Code: 01 (VCP Request)
Op Code: 02 (VCP Response)
Op Code: 03 (VCP Set)...
0
votes
1
answer
5k
views
add a new line after a specific string in a file? [duplicate]
Right now I'm using
echo sed '/\Random/a \
newly added line' info.txt
to append some text to a file but I also need to add text below a certain string let's say random, I know it is possible with ...
-4
votes
1
answer
637
views
Edit ntp.conf file using bash script to comment and replace lines
The output of current /etc/ntp.conf file in Debian 11:
# /etc/ntp.conf, configuration for ntpd; see ntp.conf(5) for help
driftfile /var/lib/ntp/ntp.drift
# Leap seconds definition provided by tzdata
...
0
votes
1
answer
2k
views
RegEx to extract file paths from a logfile
I need to get the file paths from a log file. I thought I will try this with regex.
A file path would look like this:
75/751234/751234V0001_test-tag1-tag02-75x75_01.jpg
I'm not a pro in Regex, so I ...
0
votes
1
answer
182
views
grep double quoted string along with simple string from file
Below is the output of
pg_ctl -D $PGDATA start > /tmp/startup.log
command to check if service is already running.
FATAL: lock file "postmaster.pid" already exists
Above is the string/...
-1
votes
1
answer
357
views
Copy only specific text from a file to another
I'm working on a txt file that's structured like this:
; $16
dc.b $FF
; $17
dc.b $FA
dc.b $65, $05
dc.b $F6
dc.w $0032 ; => Event1
dc.b $FF
; $18
...
1
vote
1
answer
650
views
How to replace special characters in BibTeX (e.g. {\'{o}} = ó) within a shell script?
Does anyone know of any utilities or have experience converting special characters in a BibTeX file to its proper unicode equivalent in a bash script? Trouble is I can't even find a full list of the ...
0
votes
1
answer
735
views
How to extract max value among values between 2 words with multiple occurrence from input string using shell script
I want to extract the maximum temperature value from the output of a command, which I store in a shell variable as follows:
res="$(get temperature all)"
where the result looks like
Device ...
1
vote
2
answers
2k
views
How can I delete everything after a word from multiple line in a file
In the following file:
semi1245 5465 and taxes ?>:" foo 214 sdnfv 1>?<: Wed
dsfsdf 46 and gsdgsd blah and blah taxes foo 214 sdnfv 1>?<: Wed sadfaads
I want to delete ...
0
votes
0
answers
1k
views
Commenting out a specific host configuration in a Nagios configuration file
I have lots of Nagios configuration files like the one below in a directory, and I need to remove a host from monitoring.
define host{
host_name nmo
use aix-server
alias
hostgroups +...
0
votes
0
answers
358
views
Remove all words from a file except certain words
I have a file which represent a list of SQLs where caluses.
I want to remove everything that is not the columns names, and, or and where(case insensitive). In addition if it can also remove new lines ...
-1
votes
2
answers
348
views
grep pattern next two lines and discard the pattern with one line
I have a file something like this:
dn: danan
cn: danian
cn: danian1
dn: danian2
cn: danian2
dn: danian3
cn: danian3
cn: danian4
all I want to do is grep the pattern "dn:" and print just the ...
2
votes
2
answers
310
views
deleting characters from expression using sed
I have a string in the form
|a Some text, letters or numbers. | Some other text letters or numbers |b some other part of text |c some other letters or numbers
notice the bar can be on its own, as ...
-2
votes
1
answer
3k
views
Grep and filter IP from text file
I had a log file but I want to extract specific ip from the file the log file shown as below
for the logfile i only want to get the first part of IP of every line how every I try command below it ...