Tagged Questions

Regex (or regexp) is known as regular expression matching of patterns, strings or characters in, for example, a large text file. Questions should be tagged as such whatever the programming language involved and the tag can also apply to command-line or graphical programs that have regex plugins or ...

learn more… | top users | synonyms

0
votes
1answer
28 views

Grep for specfic number format

I have a Unix script, which within has release numbers which are like this (2.19.0.32) Look like IP's but are not as some are like this 2.23.0.06.DBP. I've tried variations of this but comes back ...
5
votes
3answers
280 views

How to find all patterns between two characters?

I'm trying to find all patterns between a pair of double quotes. Let say I have a file with contents look like as following: first matched is "One". the second is here"Two " and here are in second ...
0
votes
0answers
17 views

header_checks in Postfix

I attempted to write a regex for header_checks to filter out To: header, but it is not working. The assumption is: if a header To: does not contain local domain names it will reject the message. ...
4
votes
3answers
255 views

Replace text inside quotes in vim

I have a large sql file and I would like to rename the table name from `feedback` to `comments` but I don't want to replace the word feedback in case any row has that text so I was trying to select it ...
1
vote
4answers
112 views

extract text from a file using terminal?

I want to process the body of text and extract an integer from a specific position in the text, but I'm not sure how to describe that 'particular position'. Regular expressions really confuse me. I ...
0
votes
2answers
31 views

Exclude directories from inotifywait

Doing an inotifywait to watch a directory, and trying to exclude all subdirectories from being watched while not excluding the files. inotifywait -r -q --exclude <pattern> dir/ What to put in ...
2
votes
1answer
38 views

Vi syntax highlighting for words followed by a parenthesis

I want to change the color of a keyword that is followed by a left parenthesis in a .R file. For instance, when I type length(), I want the word length to be highlighted (and not the parentheses), ...
1
vote
1answer
90 views

Fail2Ban Regex SSH Will not Match Auth.Log - Searched Everywhere for a Solution

Im trying to get Fail2Ban to work with the SSHD Config provided. When i run fail2ban-regex /var/log/auth.log /etc/fail2ban/filter.d/sshd.conf The Output is as follows ...
0
votes
1answer
23 views

Explain in details egrep line

Hi i found in the internet egrep line. The line founds the longest line in the text. But i dont understand specific elements. Maybe someone could explain me all line? Here it is: egrep -n "^.{$(wc -L ...
2
votes
2answers
82 views

Change text in many files

I have a C++ project, where each file has at its beginning some lines of license. Now, that my license have changed, I need to update it in each file. I don't want to do it manually, since its lots of ...
1
vote
2answers
143 views

How do I use regex to remove all punctuation and symbols? [closed]

I'm using Python 2.7 regex. I need to remove all symbols, punctuation, numbers and whitespace from strings in different languages. For example, these two strings: the following characters: ...
0
votes
1answer
49 views

How can I uninstall only one of the versions of Libre Office?

I have both versions of Libre Office installed - 4.3 and the default: dpkg --get-selections | grep -v deinstall | grep libreoffice shows libreoffice-avmedia-backend-gstreamer libreoffice-base-core ...
5
votes
1answer
144 views

How to rename the set of files with pattern

I have files which has name as following: P50_FR_8_q2_scrolls.csv Here the value 50 and 8 needs renaming & The results should be something like: P21_FR_3_q2_scrolls.csv I tired few ...
1
vote
1answer
140 views

Undo apt-get remove --purge

I wanted a fresh install of Python and ran sudo apt-get remove --purge python. Apparently it has killed almost everything I had installed in my system. Looking at the history.log I guess I could ...
1
vote
1answer
53 views

Ubuntu rename command regex not working

I'm trying to use the rename command to rename a bunch of images in a folder. I have this list of images, image.php?x=10 image.php?x=25 image.php?x=50 image.php?x=75 I'm trying to rename them to ...
0
votes
3answers
45 views

Batch Rename Using Regex but Mainaining Some Substring

I made a lot of research before I put this question. I found a different links to do batch rename using regex like this and other similars: *Pattern based, batch file rename in terminal My problem ...
3
votes
1answer
118 views

What happens if we add a dot at the end of sudo `apt-get autoremove`

sudo apt-get autoremove . OUTPUT: WARNING: The following essential packages will be removed. This should NOT be done unless you know exactly what you are doing! apt libapt-pkg4.12 (due to apt) libc6 ...
4
votes
5answers
222 views

Bash script programming: how to match pattern in string?

How I can get this whole value 7I45432ZX from below lines: PW*3434*453*256*PE*UB PO*00*NE*7I4543 2ZX**20140617 PW*3434*453*256*PE*UB PO*00*NE*7I4543 2ZX**20140617 This is the code I tried: grep ...
2
votes
2answers
120 views

Regular expression that matches all multiple seperate expressions

It's admission time in India and I am trying my best to get the best college I can for engg. I have got a pdf file which contains a table which looks like It contains about 2500+ entries and I ...
0
votes
2answers
58 views

Regular expression

I have a code that is looking for a specific pattern in my log files. Usually it begins with Association ID = (This is what I am looking for in parenthesis). Now the code I have made so far is ...
1
vote
4answers
107 views

Change directory structure from /YEAR/MONTH/DAY/ to /YEAR-MONTH-DAY

I need to change my directory structure for my photos from /YEAR/MONTH/DAY/ to /YEAR-MONTH-DAY I know this can sort of be done with exiftool, but it will only work on files containing EXIF-tags, and ...
1
vote
2answers
48 views

how can i find all files that contain embedded crc32's

how can I find all files that contain embedded crc32's e.g. Mydocument190_[F285E17D].pdf using the find command to clarify the crc32's are always within brackets [F285E17D] and the file names may ...
0
votes
0answers
204 views

How can I use C++11's <regex> on Ubuntu?

I normally use the G++ compiler, but I don't have anything against using clang++. Reading about this, I get the idea that G++'s implementation of C++11's regex might not compile, and if it does, it ...
1
vote
2answers
144 views

Extract full link of a div element

I'm downloading episodes from a series, but I'm tired for joining in the site, copying the link and downloading it for each episode. First, I join in the site and I get the HTML code. The code is ...
1
vote
3answers
96 views

Forming IPAddresses from Text file

I have a huge text file that contains IP addresses scrambled all over but not in one unit for example. So what the@192@ heck are you doing@168@ in my house @10@.you were not @16@ supposed to be ...
4
votes
2answers
857 views

regex search works with `grep -E` but not with bash script?

I use the same regex with grep and it gives me a match but when doing it in a bash script, it return no match. Test String(part of the file testregex.txt): <a ...
1
vote
1answer
69 views

How to get sub-string for a string using pattern analysis?

I want to get sub-string of any string using pattern analysis. Example String: <string module name="Jai" fathername="S.S. Khan" phone="1234"> <address complete="startz us" /> ...
4
votes
2answers
184 views

Using Regex Breaking a text on the last digit using linux tools like sed, or awk

I have the following list that I want to break on the digit. For example: From: 103Ru 103mRh 104 1041 To: 103 Ru 103 mRh 104 1041 I would like to use Regx with sed or maybe awk in order to ...
2
votes
5answers
269 views

Help to build this expression using sed

I have a text file and I need to get rid off the entire information just before the = symbol in each line, for example: The line: File 1515 = foo.txt needs to look like this: =foo.txt So, I had ...
2
votes
3answers
25 views

Searching through output of more command

When searching through the output of more command how can I search for a phrase that includes spaces in between? When I search for a phrase like "typedef struct audiodev" it doesn't find the phrase in ...
1
vote
1answer
36 views

Regular expression problem, not finding the results I'm expecting

I am writing a script to install some things and I'm having trouble with a regular expression I am using. I have the Wine repository in my apt sources (ppa:ubuntu-wine/ppa) and I am using the ...
2
votes
1answer
89 views

Capture groups are ignored when renaming files

I have a number of files in this format: ##.## - File name.mp4 I want to rename them to: s##e##.mp4 This is what I came up with: rename -n "s/^(\d{2})\.(\d{2}).*/s$1e$2.mp4/" It works when I ...
4
votes
1answer
3k views

Using Modifiers of Perl-compatible Regex (PCRE) in grep

According to grep --help and man grep, we can use the -P option in order to interpret the pattern as a Perl regular expression (PCRE, to be precise), instead of the default POSIX basic regular ...
0
votes
3answers
66 views

How to recursive regexp rename double dashes

I am using Wordpress Eazyest gallery to create 2000 galleries. Some files have double or triple dashes in filenames. For instance: abc---def.jpg These files are uploaded via FTP. On Wordpress admin ...
1
vote
1answer
692 views

How to replace strings in file without regex?

I need to replace some strings in files (from command line) but I don't want to use sed -i because my string contains lots of funny characters which need to be correctly escaped. Is there a way to ...
0
votes
1answer
263 views

how can i use grep to find IPV4 Number in a pcap file with regx syntac?

I'm new in ubuntu. I have this IP regex '\b((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.|$)){4}\b' I have a network pcap file, I want to use this regex and the grep -e to find all IP address in the ...
3
votes
1answer
99 views

Did grep change how it uses regexp?

I used to run commands like: find /dev | grep sd* to output a list of all the drives attached to my computer. It appears that I now have to add any random character before the star in order to get the ...
0
votes
1answer
44 views

Formatting a file to use it with fortune in the terminal

I have a big text file with 'Terms' and its 'Definition' separated by spaces(variable). I want to use it in fortune cookie format. Current file format: **term1** this is my definition with ...
0
votes
1answer
241 views

Passing Int variable to re.findall

I'm trying pass year variable to re.findall, but it doesn't work(no errors). Can anyone specify where I'm going wrong? year=2013 links = re.findall(r"('+year+'-.*\/t.*.html)", line)
0
votes
2answers
204 views

Extracting specific data in a file using regex [closed]

Following info i want to extract from a file which has different version,release date,CVE number. Can anyone show me how to retrieve that information using regex..? Sorry if this is a terrible ...
1
vote
1answer
253 views

Extracting URL links from a File

Following code is to extract /support/security/bulletins/*.html links from a file(urlfile contain about 1000 links) to urlsort file using regex,But i'm weak in regex can anyone show me how to do ...
2
votes
2answers
97 views

Removing a string of files with rename

I have been trying to batch rename a bunch of files so that they are consistent and fit within the name structure that I have come up with. For instance,I am renaming comics, and so I have a directory ...
1
vote
1answer
568 views

Grep Regex match not returning result as expected

I have several Ubuntu servers and there is some behavior that has me curious. On any newly installed machine (Ubuntu Server 12.04.3 LTS), if I run: echo "testbla123" | grep -P -o [0-9]* This will ...
1
vote
1answer
206 views

Use Postfix to dump mails to local folder using regex

How do I use postfix to filter certain emails (by domain or sender) and for those who fall under the rule (filter) save locally and those who doesn't to relay regularly ?
3
votes
1answer
39 views

REGEX behaves differently!

When running the following echo "abc>asf<tfg"|sed 's/.*>\(.*\)</\1/' The output is: asftfg I don't understand why tfg gets printed? My expected result is asf. Though, it works ...
1
vote
0answers
143 views

Grep word in one file, and use that word to match in another file, adding the thing that follows the match [closed]

I want to grep several words in file1, and use each word to grep what follows after its match in file2. And then I want to add the thing that followed the match to the word I used into file03, so that ...
-1
votes
1answer
171 views

Complicated batch rename file problem

I did find the program pyRenamer, but I don't seem to understand it. I have hundreds of files with name like main.php?g2_view=core.DownloadItem&g2_itemId=6027&g2_serialNumber=3 here ...
2
votes
1answer
170 views

How to monitor a local file for changes, apply a RegEx replace on it and save/overwrite to a destination file?

I'd like to start a script or something that watches a text file for changes. When the file changes I want to run it through a RegEx parser to replace some text and then output the modified file to a ...
1
vote
1answer
161 views

how to parse watch command output to last 5 digits?

From the command watch -n1 "ifconfig eth0 | grep GiB". I have output given below, Now i just want the last 5 digits before (GiB). I wrote an regex for it, and it seems to work ...
8
votes
2answers
4k views

Pattern based, batch file rename in terminal

I need to rename the following: file_001_loremipsum.png file_002_dolor.png file_003_sit.png file_004_amet.png file_105_randomness.png into upl_loremipsum.png upl_dolor.png upl_sit.png upl_amet.png ...