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
2answers
41 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
236 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
43 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
55 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
228 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
15 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
26 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
33 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
269 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
32 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 ...
0
votes
1answer
183 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 ...
2
votes
2answers
262 views

grep stirght from a pcap file (no tcpdump)

I'm trying to figure out the correct command syntax. I have a pcap file, and I want to use grep, and grep only to take out all of the uniq ip addresses from without the file So assuming the file is ...
0
votes
1answer
138 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
88 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
30 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
125 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
136 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
145 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
2answers
77 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
354 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
170 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
36 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
116 views

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

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
120 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
146 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
113 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 ...
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 ...
0
votes
2answers
915 views

Inserting variable into sed command in bash script

I have text file similar to this: Some-text Keyword Some-text Some-text Keyword Some-text Keyword Keyword I want to replace every "Keyword" with "number.extension" where number is 1 at first ...
2
votes
1answer
143 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 ...
1
vote
2answers
63 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 ...
2
votes
1answer
450 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 ...
3
votes
2answers
769 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
4answers
2k 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.
1
vote
1answer
456 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 ...
0
votes
0answers
49 views

sh schedule with regex

Does someone know how to setup Source hashing with regex? What I want is the follwing: I have 3 ubuntu servers. 1 Loadbalancer, the second is transparent and the third has a caching mechanism (Apache ...
4
votes
3answers
171 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 ...
3
votes
3answers
413 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 ...
8
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 ...
2
votes
3answers
228 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 ...
4
votes
1answer
382 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 ...
5
votes
2answers
7k 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 ...
1
vote
2answers
215 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 ...
0
votes
2answers
122 views

Python: Regex filter ids divisible by 3

Hi I have a list of ids separated with commas and I need to take the ids which are divisible to 3.
1
vote
0answers
121 views

What does this regex mean and why [closed]

$ sed "s/\(^[a-z,0-9]*\)\(.*\)\( [a-z,0-9]*$\)/\1\2 \1/g" desired_file_name I apreciate it even if you only explain part of it or at lest structure it with words as in ...
4
votes
1answer
113 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 ...
1
vote
1answer
7k 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 ...
1
vote
3answers
192 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 ...
2
votes
3answers
1k 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?
1
vote
5answers
3k 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
2answers
551 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 ...