Questions tagged [regular-expression]

Regular expressions are a means of matching a pattern of characters within a string.

119 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
0
votes
2answers
318 views

Bash script variable with if else statement but with loop

I am not very experienced with bash scripting. But I am trying to validate individual xml files with corresponding xsd files in a directory. The beginning name does not change but the dates changes. ...
0
votes
1answer
676 views

Regex for time stamps and corresponding lines

I have a human written text file that contains time stamps in form of dd-mm-yyyy,HH:MM or HH:MM:SS. I have managed to extract time stamps from text file using regex but I would like to also get a line ...
0
votes
1answer
110 views

What does a “*” at the start of a regular expression do?

In this case discussed: find (GNU findutils) 4.5.11 grep (GNU grep) 2.20 Let's say I have a directory that contains a bunch of files. I want to find the files named jtobdops02.key and jtobdops.02.cer....
0
votes
1answer
870 views

How can I use part of match in Regex to generate filename of action?

I am using CentOS6.5 that include rsyslogd v5.8.10 There are 20 process program in my server.I want to receive logs use rsyslogd and hope to store in different log file according identity of process ...
0
votes
2answers
152 views

Collecting network information

I need to collect information about the network usage of each process. Nethogs presents the data I need in real time, I am trying to save the output to a file in order parse it and plot the data. ...
0
votes
2answers
70 views

finding how many options ls have

Just for practise i want to find out how many options does ls command have. I have written following piece of code man ls | grep -o -i '\-[a-z0-9]$' Why does this piece of code only printed -C and -...
0
votes
0answers
175 views

Finding word with centain length containing characters from interval

I am trying to print all words that are 3 chararcers long and those characters are from [a-s] interval. I have tried following grep '\<[a-s]\{3\}\>' file.txt which outputs nothing , i have ...
0
votes
0answers
177 views

swap strings of text inside vim using regex

I am working with a file where I need to swap "string A" and "String B's" locations simultaneously with a regex inside the vim. Here is an example line of code: succ_1st=`grep 'resulted in successful ...
0
votes
1answer
70 views

subtract dates from two files for same process

I have initiated 50 processes and in one file "say start_time", I have stored when process was started and in another file "say end_time", I have stored when process finished. files are like below - ...
0
votes
1answer
659 views

Use sed to only replace namespace in an element that has a parent element with a given attribute value

I want to replace the namespace in an xml file using sed (I've given up trying to do it from ant, where it is required). The main issue is that that there is a repeating list of elements - not all of ...
0
votes
0answers
73 views

Regex for a non-fixed pattern

I am trying to come up with the right regex (compatible with python) that would match a file that contained sample input as follows: On the third day of Christmas my true love sent to me: three ...
0
votes
1answer
110 views

Emacs: query-replace prepend text to the found string

The scenario is that I am trying to append a new class to all the style declrations in my css file. So .oldclass{ float : left; } should change to .newclass .oldclass{ float : left; } The ...
0
votes
1answer
167 views

SMTP log anonymize script

I have a SMTP log with records in the format below: 6,222.3.4.5,3040,100.2.3.4,25,UNKNOWN,0,1,……,9337bc-929a-34c0-29a8-b3a89c834b29 ,protocol,SMTP ,745663746,STATUS-COMPLETE ,VALID 6,222.3.4.5,...
0
votes
3answers
524 views

Finding and replacing text inside awk block

I want to find and replace a value inside awk block. Here is a sample input file to my script P1 10,9:11/18013013582 ,10:1 ,167:0 ,487:5/E.164 11,9:15/310410532169026 ,10:60 ,167:0 ,487:4/IMSI 12,18:...
0
votes
1answer
350 views

How can I use gsub with a pattern? And how to tell it which file to awk?

I've read here that I can replace the values of all columns containing a particular text using awk -F'\t' -vOFS='\t' '{ gsub("CC", "C", $1) ; gsub("AA", "A", $1) ; print }' But where do I tell awk ...
-1
votes
0answers
24 views

How to insert a variable at a particular location in a URL

I have bitbucket URL in a shell script which looks some thing like below https://username@bitbucket.com/scm/~username/demo.git When ever i run the shell script it prompt for password but instead of ...
-1
votes
1answer
80 views

How do I exclude pre tags from HTML minification using sed?

I am trying to minify HTML using sed My problem: I don't want to minify anything inside <pre> tags, but can't make it work.. Here is what I am using: sed ':a;N;$!ba;s@>\s*<@><@g' $...
-2
votes
1answer
124 views

grep to find lines that contain six or more non-vowel characters in a row

Using grep and regular expressions, I need to output all lines in a file that contain at least six characters in a row that aren't vowels. This includes any consonants, punctuation, numbers, etc.
-2
votes
1answer
2k 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 ...