All Questions
76 questions
1
vote
2
answers
312
views
Remove exact line from file if present, leave the rest of lines; error-handling - how to go about it
I am not exactly sure how text processing should be done in a good way, so let me ask.
I have this file: ~/.config/mpv/input.conf containing possibly other options as well as v disable.
If I want to ...
2
votes
4
answers
700
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 ...
10
votes
7
answers
4k
views
How to grep everything BUT the match AND the previous line
I have a text file, and I have a pattern that I want grep not to match. Thing is, I also want the line before not to match.
My file:
line 1
line 2
pattern
line 4
And I tried cat file | grep -v ...
0
votes
1
answer
221
views
Read subdirectory names and split into subdirectories based on dir name
This is probably really simple but I'm ox-hilling it for the better part of the day.
Problem:
I have several folders coming out of an app that I need to get into sub-folders. I'm going with separators ...
1
vote
2
answers
324
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
...
0
votes
1
answer
597
views
grep -v not working inside shell script
I have this line inside my shell script:
tomcatPID=$(ps -ef | grep tomcat | grep $TOMCAT_ACCOUNT | grep -v grep | grep -v restart | awk '{print $2}')
I made sure that the $TOMCAT_ACCOUNT part is okay....
-3
votes
4
answers
351
views
Bash Script help- Text Parsing & Output
I am having text file of the following type,
a b c d
-- -- -- --
1 ok device issue Some Action which
has to be taken which
...
-1
votes
3
answers
864
views
Extract content of a specific column with awk/sed [closed]
Provided file:
$ cat CronConfig
`FILE SYSTEM`
`------------`
warningThreshold: 77
criticalThreshold: 99
`MEMORY`
`-------`
warningThreshold: 66
criticalThreshold: 88
`CPU`
`----`
...
0
votes
1
answer
51
views
Read a file and search for 1st occurrence of specific string and matches certain patterns only
This question is a continuation of a question I have asked earlier
Sample data file:
empid;A1001
empname;ABC
salary;3000
dept;ABC
age;24
dept;112
JOD;20170101
empid;#201
empid;A2001
salary;5000
...
2
votes
2
answers
629
views
Is there any use case for `sed -n "/regexp/p"` in a world where grep exists?
sed -n "/regexp/p" will print only lines that match regexp and no other. This seems exactly equivalent to what grep does. The only use case I see to use this construct instead of grep is if you're ...
0
votes
2
answers
283
views
Filter a file, multiply a value in the lines that contain certain string, return all lines
With grep filter a file, from that filtered lines do a math operation on a specific column, only in the lines that contains a string "value=", return all the lines from the first grep filter ...
5
votes
3
answers
2k
views
pruning subdomains of other domains in a file using script (bash, awk or similar)
I have a huge size file (ten thousand entries) comprising of domains (in random order, but no duplicate domains and with an arbitrary number of subdomains), here is a little example:
domain.com
...
3
votes
3
answers
2k
views
Grep complete name including dot in the word
In a ksh shell script I am using a grep command to get a specific word as shown below.
$ cat file.txt
abc xyzdef.123 def.jkl mnopqrst
$ grep -o "\wdef\w" file.txt
xyzdef
def
I want output to be ...
0
votes
1
answer
921
views
Insert characters at the middle and the end of a line with specific line length
Currently I am working on a folder of files, and each file have some lines as follows:
abcde fghij
abcde fghij
jklmn pqrst
..... .....
These lines have a specific line length 43. At the ...
1
vote
1
answer
369
views
for loops to grep multiple texts from parent file to multiple files in single command
I have 29 fasta files (.fa as extension) named and stored sequences according to their genes.
(Example: ribosomal protein L1, ribosomal protein L6P/L9E,...)
There were a total of 722 species ...