All Questions
Tagged with pattern-matching shell-script
22 questions
1
vote
2
answers
43
views
How can I delete everything before and afrer match pattern from pdb file?
I'm beginner in bash scripts, but I try to delete everything in my pdb file (test.pdb) before REMARK time 20.00 and from REMARK time 30.00 to the end of this file. I'm using to this sed command, which ...
0
votes
1
answer
657
views
select lines in file with same string pattern
Let´s suppose I have the following file.txt:
asiub
sj
abq
b aia
ainp oo
test = 123d
sub ,.
aiba 87ab
test = 129szs bq
test = aqua
ayqvq 133s
I want to print only the lines of file.txt that contain ...
-1
votes
4
answers
2k
views
Linux - Find all occurrences of a certain pattern in a line of a file
I have a file in Linux which contains a line like :
(memberOf=CN=Group1)(memberOf=CN=Group2)(memberOf=CN=Group3)(memberOf=CN=Group4)
My goal is to populate the list of groups that is present in the ...
1
vote
2
answers
308
views
grep partial ip number from the file
I have to sort IP addresses into classes, so I can block entire class in myfirewall. It works fine when I try to do for /24 class, but not so well when do for /16 class. I have a list of IPs in the ...
0
votes
1
answer
207
views
Instruct shell script to do a task if the output of a program contains a specific word
I need to create a program in Bash that launches a command, check if the result contain a word, and do something if it does.
Example: I need to check if a printer is online with
lpstat -p [printer ...
0
votes
2
answers
43
views
Check if the second integer of a line in a file matches
I have a file with the below format of entries.
$ cat mw.hosts
host23v0242 USER=wsadmin MOUNTPOINT=/web
server21v0243 USER=wsadmin ...
-1
votes
1
answer
126
views
How to search for a pattern and print two lines before it for all matches found
I have a file with information about different protein entries. Each entry includes: details of the sequences (top line), number of times any alphabet is found in the sequence (second line) and the ...
-1
votes
1
answer
137
views
Custom data formatting and pattern matching
I am trying to format custom data using pattern match. I am not getting expected format. Though I am not shell script savvy but I was able to build a script based on references from multiple sources ...
1
vote
1
answer
301
views
Map field of first file based on patten matching in second file
I have two tab-delimited files where I need to match text in the first column of file 1 to any position in lines of file 2. Upon a match I then want to print what's in the second column of the ...
4
votes
1
answer
929
views
How to ensure user input consists of exactly 6 digits
I am running HP-UX 11.23 and have a bash script that reads two inputs.
Both inputs need to be exactly 6 digits long.
What is the best way to read the input and if its not 6 numbers
ask the users to ...
1
vote
1
answer
937
views
Conditional regex pattern matching in a korn shell script
I have started learning Unix shell scripting using korn shell. Please enlighten me finding the mistake I am doing while writing a ksh code for below a problem as stated below :
My script takes 2 ...
1
vote
1
answer
464
views
My grep for a process returns multiple strings with similar name
I have a script that checks processes on our Linux servers.
An example would be we have a component named ebond-dbreader-bbg on server 1 and also a component named ebond-dbreader-bbg-cbrt on server 1....
0
votes
1
answer
54
views
if condition between lines inside different lists, parse lists for matches, then use cp
Please, could anybody kindly suggest me how to do?
I have two lists (both with sha1sums and their relative filenames) but formatted differently, here's an example:
list01.txt
artist'ssomesong.mp3,...
0
votes
2
answers
490
views
Bash brace expansion with variables for pattern matching
I want to loop through all files matching a pattern of the form
for file in {prefix1, prefix2, ...}*{postfix1, postfix2, ...}; do
How can I programmatically replace {prefix1, prefix2, ...} with a ...
0
votes
2
answers
238
views
Matching columns of File1 to columns of file 2 and printing them in a file using awk
I am new to awk and trying to compare ":" separated columns 1(eg., chr10) and 2 (eg 10000003) between file1 and file 2 ; and write the matching lines into a new file using awk.
File 1:
chr10:...