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

1
vote
0answers
39 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
27 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 ...
1
vote
0answers
33 views

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

I'm running Lubuntu 13.04 (Raring Ringtail). 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 ...
1
vote
1answer
33 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 ...
2
votes
2answers
98 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
191 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
65 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
59 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 ...
0
votes
0answers
94 views

regex to exclude all not hidden files/dirs in remastersys

I want to exclude all not hidden files and directories from my remastersysbackup via a regular expression. In other words, I aim at doing a backup where my home folder is containing only hidden ...
1
vote
0answers
73 views

Searching files - regular expressions with square brackets

I use gnome-search-tool for searching files/folders. There I can put regular expression to filter through file names. I need some help with my custom filter(search). My folders have format: ...
1
vote
1answer
156 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
497 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
185 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
247 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
37 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 ...
3
votes
3answers
93 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
191 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 ...
4
votes
2answers
660 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
106 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
182 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
2k 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
165 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
1answer
55 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
91 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
86 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
2k 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
159 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
3answers
741 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
2k 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 ...
0
votes
2answers
361 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 ...
0
votes
2answers
289 views

Problem using `sed` to colorize `ls` output (Tenth back-reference `\10` not working)

I had asked this question a while back: Is it possible to colorize permissions-part of the output of ls? While the accepted answer in that question is OK, I now want to do the same thing without ...
0
votes
1answer
1k views

PowerGREP alternative - sed, awk… GUI? [closed]

I'm used to this tool from Windows, and I run it under Wine in Ubuntu. Crashes from time to time under Wine, but I can't find any replacement for it. Alternativeto IMHO totally misses features ...
3
votes
1answer
702 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 ...
1
vote
1answer
646 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 ...
9
votes
3answers
3k 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 ...
1
vote
2answers
489 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 ...
3
votes
2answers
947 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 ...
1
vote
1answer
49 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/) { ...
3
votes
3answers
976 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 ...
5
votes
4answers
1k 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, ...