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

10
votes
2answers
2k views

apt-get remove with wildcard removed way more than expected. why?

Last night I was trying to burn CDs. Being annoyed with k3b and choosing to use brasero instead, I went to remove k3b. I typed in: sudo apt-get remove k3b I hit tab twice and saw that I had both ...
9
votes
3answers
5k views

Recommendation for Regex editor?

I asked for recommendations for Regex editors on stackoverflow a while ago. Following is one of the replies: What is "good" depends on what is most useful to you. For me, though, these are ...
6
votes
5answers
3k views

Text editor capable of running complex Regular Expressions?

I want to find a text editor capable of running and mainly storing regular expressions for later re-use. It should also be able to run them across multiple files. I know I can get all that with grep, ...
5
votes
2answers
8k views

Install Regex plugin for Gedit

I am using Ubuntu 12.04.I want to install Regex Search and Replace plugin for Gedit.So can some one please tell me where can I get it and install it.Any help and suggestions will be highly ...
4
votes
3answers
208 views

bash escaping and find command

I trying to remove boring \-escaping from this command: find . \( -name '*.mp3' -o -name '*.jpg' \) -print by wrapping it in single quotes: find . '( -name *.mp3 -o -name *.jpg )' -print ...
4
votes
2answers
585 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 ...
4
votes
2answers
104 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 ...
4
votes
2answers
2k 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 ...
4
votes
1answer
439 views

How can I use GPRename's regex feature to reinsert the matched-group into the 'replace'?

I've been using GPRename to batch-rename files; this is rather more efficient than individually correcting each file, but still seems to be less efficient than it might be, primarily because either I ...
4
votes
1answer
122 views

Custom GREP with asterisks and anchors?

I have lots of EDI files (which is pretty much a single line of gibberish text) that are about 300mb/pcs. I'm looking to pattern matching this: `*UP*605284466346 {lots of other stuff inbetween with ...
3
votes
2answers
836 views

How can I parse a YouTube URL?

How do i extract only http://www.youtube.com/watch?v=qdRaf3-OEh4 from a URL like http://www.youtube.com/watch?v=qdRaf3-OEh4&playnext=1&list=PL4367CEDBC117AEC6&feature=results_main I ...
3
votes
3answers
2k views

grep for string not preceded by another string

Is it possible, using grep, to search for instances of John Smith but exclude instances of Mr John Smith?
3
votes
4answers
3k views

How to search for all the files starting with the name “ABC” in a directory?

I need to search for files starting with some particular name. There can be multiple files starting with a particular pattern and I want to list all such files present in the directory.
3
votes
2answers
3k views

Questions about using Regex Search & Replace in gedit

I am trying to use Regex Search & Replace plugin of gedit. I want to search a digit that repeats 2 or 3 times, so I thought the regex was [0-9]\{2,3\} But it doesn't match the target it ...
3
votes
1answer
93 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 ...
3
votes
1answer
8k views

How to find a folder on my server with a certain name?

I have a directory somewhere on my server wth the name "exampledocs". I tried to find it's location using: ls -d */ | grep -E 'exampledocs' and find * -regextype posix-extended \-regex ...
3
votes
1answer
1k views

How do I ignore a conflicting package on a regex match in apt-get?

I'm trying to install all but one of the R packages which are currently in the Ubuntu repositories: However, when I go to do so sudo apt-get install 'r-cran-*' I get an error: Some packages could ...
3
votes
3answers
1k views

regex on the shell?

I wanted to do some simple regex so i am trying to get the 16. I tried grep but i dont see how to write \1 or $1 to only output the capture data and i tried sed but i think i did it wrong due to ...
3
votes
1answer
38 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 ...
3
votes
3answers
472 views

Why Kodos is not part of the available packages in Ubuntu Quantal 12.10?

I'm running the 64-bit edition of Ubuntu Quantal and I've used extensively Kodos, a user friendly regex editor. It seems that for some reasons, this package has been deleted from the Ubuntu Quantal ...
2
votes
5answers
254 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
2answers
100 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 ...
2
votes
3answers
254 views

Trying to do a batch rename, can't figure out the proper RegEx

I'm trying to rename my movie collection. All of the files are currently named using dots instead of spaces, i.e. Men.in.Black.avi. I want to replace all of the dots with spaces which isn't terribly ...
2
votes
1answer
154 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 ...
2
votes
1answer
522 views

How do you use sed to edit a CSV file?

I have a CSV file like this: hostname1 | role1 | environment | tag,list | | hostname2 | role2 | environment | tag,list,longer | | hostname3 | role3 | environment | | | I need a sed expression that ...
2
votes
1answer
45 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 ...
2
votes
1answer
1k 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 ...
2
votes
1answer
155 views

Delete lines starting with pattern from a file

I tried several commands: tr, sed but to no avail. Here's the file: > ... > ... > setEPS() > postscript('images/boxplot_default.eps') > ... > ... I want to delete those two ...
2
votes
3answers
18 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
3answers
74 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 ...
1
vote
2answers
227 views

Literal dot confusion, copy all hidden files

It works fine when I copy all hidden files using regex: cp -r source/\.[^.]* destination/ and it just copies exactly files beggining with a dot . . However, I found the following works also: cp ...
1
vote
4answers
63 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
1answer
469 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
2answers
65 views

Unexpected anwer from the following regex?

I have this following file:- $ cat numbers a1 12 12345 123456 19816282 1@$%6 I am using grep "^[0-9]\{1,6\}$" numbers which is giving me the following results:- 12 12345 I was expecting 1@$%6 ...
1
vote
3answers
195 views

Simple way to get all .o files but one

I'm trying to link all *.o files from another folder and would like to in my Makefile do something like; g++ *.o (folder/*.o and not folder/main.o) -o bin Is there someway I can use somekind of ...
1
vote
1answer
2k views

How to make grep display only the matching regexp?

I am trying to find data from files using grep, but grep usually prints out the filename as well as the line where the term is found. In this case, I am looking for a special regexp and I want grep ...
1
vote
5answers
4k views

How to programatically remove empty new lines from a file?

I need to remove empty new lines from text file in terminal. Example file 123 123 123 123 123 123 I've searched in google a bit but only solution found was sed '/^$/d' myFile > tt and it ...
1
vote
1answer
59 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" /> ...
1
vote
1answer
32 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 ...
1
vote
1answer
128 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 ...
1
vote
1answer
494 views

How do I install Kodos in 12.10?

In previous Ubuntu version I used Kodos extensively. But the package has been dropped in 12.10. It's a neat regular expression testing tool. It's hard to find an alternative that is not Windows only ...
1
vote
2answers
586 views

gedit 3 regex search replace plugin port

So i have been trying to install this plugin: http://halfhourhacks.blogspot.com/2008/03/gedit-regular-expression-plugin.html in gedit 3.2.1 but there seem to be some issues. I have modified the ...
1
vote
2answers
573 views

Has this Windows application been successfully installed via Wine?

I just installed Expresso via Wine Windows Program Loader. The installation seemed to be fine. But when I click the program item from Applications -> Wine -> Programs -> Expresso -> Expresso, the ...
1
vote
2answers
32 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 ...
1
vote
2answers
81 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
1answer
178 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 ...
1
vote
1answer
182 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 ?
1
vote
1answer
54 views

/gc is not picking up Mississippi in my list - what is the problem here?

#!/usr/bin/perl #match5.pl open(INFILE,"test2.txt") || die "$!"; print "Enter the pattern you wish to match: "; chomp(my$pat=<STDIN>); my$num_letters=0; while(<INFILE>) { if(/$pat/) { ...
1
vote
2answers
87 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
0answers
129 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 ...