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
2answers
59 views

Grep in bash script won't work properly

I know there are many similar questions arround the Internet, but I couldn't find a solution for my specific problem. I made this script for an assignment, where I want to find which combinations ...
0
votes
0answers
23 views

Regular expression to pull db table names from .sql files

I'm looking to search my directory of sql queries and for the most prevalent database tables in all of the files. To do so, I'm hoping to use grep to isolate these names but I can't quite figure out ...
0
votes
1answer
30 views

Ubuntu alias rename directory issue

I have Ubuntu 14.04 Trusty Tahr installed in my system. I have created following alias in my '~/.bashrc' file to make renaming directories recursively in current folder, as easy to use short command. ...
7
votes
1answer
250 views

Shorter way to apt-get install php7.0-{some modules}

I am currently installing php7.0 and was wondering if there is an shorter way to install the modules. normally I type: apt-get install php7.0 php7.0-fpm php7.0-mbstring php7.0-mcrypt php7.0-...
-1
votes
1answer
53 views

Reg ex - awk - grep from getline result [closed]

I have a expr in awk, but I can't grep the result echo 34100 | awk '{expr $1 / 33.7 | getline result;}' -> sh: 1: 1009.89: not found the calculation is ok but I need to have the 1009.89. Could ...
3
votes
3answers
224 views

How to rename all files in folders with pattern

I have a bunch of files like: bla.super.lol.S01E03.omg.bbq.mp4 bla.super.lol.S01E04.omg.bbq.mp4 bla.super.lol.s03e12.omg.bbq.mp4 I need to rename them all like: s01e03.mp4 s01e04.mp4 s03e12.mp4 ...
0
votes
0answers
81 views

How I can install regex package for python 3.4 without errors?

I have a little problem (or a big one?). I want to install regex package for Python 3.4. But then I use pip or our installation methods I am getting error: universe@universe-AOD270:~/Downloads/...
0
votes
2answers
36 views

Replacing a Substring with sed

So I've got a line that looks like this ish somelongbullshit:888:morelongbullshitthatcanhaveanything And I want to replace the second : with a tab character. I can reliably match the substring I ...
0
votes
2answers
46 views

searching a file [duplicate]

I want to find in the system a file, and I know part name of it. How could I do that? I tried unsuccessfully the command: find / "*partname*" The problem is probably very easy however I cannot find ...
4
votes
1answer
51 views

Why doesn't cp detect '\ ' (backslash+space)?

I was trying to write a shell script to copy files. Here is what I have done. workingDirectory=$(pwd | sed "s/ /\\ /g") Now echo $workingDirectory shows /home/user/Documents/Learning and ...
0
votes
1answer
32 views

Does GNU awk accept intervals specified using braces in regular expressions?

Which types of regular expressions are recognized by awk? This command echo "aa" | gawk '/a{2,3}/ {print}' does not return anything, whilst echo "a{2,3}" | gawk '/a{2,3}/ {print}' returns a{2,3}....
5
votes
4answers
2k views

How to rename these files with regex?

I can't write a regex code for that. Microsoft Windows has changed my files' names and I want to remove the date from this names. How can I do this? (Names are below.) icon-culture (2015_09_04 ...
3
votes
3answers
408 views

What does a leading asterisk mean in extended and basic regular expressions?

What are the semantics of * at the beginning of a RE? It is documented (man 7 regex) that for basic REs it matches only * (i.e., it turns to an ordinary character), but what happens for extended REs? ...
1
vote
2answers
32 views

Find file based on content of entire file, not per line

Can I search for files with a rexexp that is matched against the entire file? Let's say that I have these files: //file1 foo bar //file2 bar foo I want to find files that end with "foo". If I use ...
0
votes
1answer
45 views

How to list file names with a total of X letters

Say I have a list of the following files in my current dir: lab1.jav mytst2 pie.c prog2.c tst3.ex tst5:5.tlab2jav lab2jav.ext new.c prog1.c tst1 tst4.exc tst6:6123.tA7-tst.c fred....
0
votes
0answers
115 views

Fail2ban-regex filters not working in Nginx (returning Missed line(s): /var/log/nginx/access.log)

I've set up Fail2Ban on my Nginx Ubuntu 14.04 server following these instructions, which seem to have worked for most folks. When testing any of the filters that point to /var/log/nginx/access.log ...
2
votes
3answers
151 views

keybind to toggle touchpad in lubuntu (openbox)

I'm using lubuntu. I want to add a shortcut to toggle (turn on and off) my touchpad. I know I need to edit the xml file in ~/.config/openbox (in my case it's lubuntu-rc.xml) as described here and ...
3
votes
2answers
451 views

Regular expressions VS Filename globbing

I know that Regular expressions are to be used only with characters and strings, but sometimes I find them in the names of files. My question is: are regexes only used with characters or also with ...
0
votes
1answer
559 views

search using regular expression with alternation

I'd like to search files containing G Bush, J Bush, B Bush, or H Bush The following command can achieve the goal: grep -rnE "G Bush|J Bush|B Bush|H Bush" Can we do something like grep -rnE "{G|J|...
0
votes
0answers
92 views

Best RegEx tools

I am new in Ubuntu, and am looking for an offline RegularExpression tool. I have been using RegEx101 and now it gives an error by saying Catastrophic backtracking has been detected and the ...
0
votes
1answer
14 views

locate: ignore .git .svn and hidden folders in general when using willcard

I try to do locate -i -l 256 -r '*testhack*' and I get all hidden files as results polluting my limited result list, things like /home/kwaadpepper/testhack/TwitterReport/.git/objects/9a. I think that ...
0
votes
0answers
1k views

Log Sifting: Rewrite Logs for Human-Readable Verbage

My goal is simply to build a reworded log containing the lines where an external IP address interacted with an apache2 server. So far, I have come up with the following: #!/bin/bash # apache2 log ...
6
votes
3answers
233 views

What is the sed comand to fix this file so last value on each line is double quoted

I have a file containing two million lines of the form: "00005cea-668e-4475-9e19-92a25c8b74fb",129.24728",D# the last value should actually be: "00005cea-668e-4475-9e19-92a25c8b74fb",129.24728,"D#"...
1
vote
2answers
31 views

patterns symbol in regular expression [closed]

I am new to regex, Can anyone explain for me the patterns: (<form[^\a]*</form>|<FORM[^\a]*</FORM>) (method="[a-zA-Z]*|METHOD="[a-zA-Z]*)
0
votes
0answers
29 views

USB 3 External Hard drive SMART fails

I am trying to use SMART to check an external hard drive, however when i try to use SMART (from Disk) the option is greyed out and i cannot use it, whether the HDD it is mounted or not. I have ...
1
vote
3answers
190 views

how to copy only pdf from folders and subfolders?

I have a folder with about 20 subfolders, each with 10-15 subfolders. Is there a way, using CLI to move only PDf files to a new folder?
0
votes
3answers
67 views

Reverse string matching

So basically what I want to do is use a grep,sed or awk command (I'm not picky) that can do the following. I know how to go from Vuln 1 to OS1 but not vice versa. Input: test.txt Vuln 1 OS1 OS2 ...
1
vote
2answers
103 views

need help with pattern to extract a string?

i am having trouble coming up with the proper regular expression to match a string. i have this string asdasa asdas asdhhgfh dfgdfdasa ttte aa1 asasda aa2 i'm trying to use regex but can't ...
0
votes
2answers
369 views

move files matching a specific pattern

How can I move files in a folder with a specific pattern to the destination folder? I want to move files with names in the range [00-09] in the 4th column when separated by delimiter "-". ls | cut -...
0
votes
2answers
63 views

Use regexes to reformat a reference title in a BibTeX file

I have many references in a BibTeX file as follows: @inproceedings{lechartier2014static, title={Static and Dynamic Modeling of a PEMFC for Prognostics Purpose}, author={Lechartier, Elodie and ...
0
votes
0answers
146 views

C++ and regex using gcc 4.9.1

Good day, I'm trying to use regular expressions within my C++ program. The regular expression I use is simple and works as intended when I try it in an online debugger. The code: /* _token = "WIDTH"...
1
vote
1answer
87 views

Sequential renaming of files

I found an answer for zero-padding numerical filenames which works fine for renaming filenames as follows : 1.jpg > 00001.jpg 2.jpg > 00002.jpg . . . 9.jpg > 00009.jpg That uses the ...
0
votes
0answers
37 views

LFTP downloads some folders but deletes others after downloading files

I'm using the mirror command combined with regex to filter out rar files. LFTP downloads most folders but inexplicably deletes a few folder while it's still downloading a file (usually large) and then ...
0
votes
1answer
23 views

Problem with rename and mask the point

Lets assume that I want to rename a file: "topography_9x9._001.png" to "topography_9x9_001.png" I would use rename -n s/9\./9/g topography_9x9._001.png renamed as topography_99_001.png Why ...
1
vote
1answer
513 views

How can I delete all my core files cleanly?

My computer at work has a tendency to generate an excessive amount of core files, which can be useful for debugging, but slowly take up all of the available space on my computer. I made this command ...
-1
votes
1answer
306 views

How to install i386 (32bit) boost-regex library to amd64 (64bit) system, 15.04

I tried to use this command: sudo apt-get install libboost-regex1.55-dev:i386 And i have some errors: Reading package lists... Done Building dependency tree Reading state information... Done Some ...
2
votes
3answers
206 views

How can I divide an output with 2 delimiters?

By dividing with the "·" and " " characters, I would like to turn this: Hel·lo my name is E·ric To this: Hel·lo my name is E·ric Hel·lo my name is E· Hel·lo my name is Hel·lo my name Hel·lo my Hel·...
0
votes
3answers
110 views

Get the last modification time of file

I want to extract the stretch Jul 22 from the output : -rw-rw-r-- 1 douglas douglas 92188 Jul 22 08:47 master-terfron-21-07.log This is the output of the command: ls -l *.log How would i use a ...
3
votes
1answer
354 views

How to mark matching GREP string while redirecting output to file

I am trying to use grep to find all matching strings in file and output them, in context of the line, to another file, while adding some kind of marks (ideally two asterisks) on each side of the match....
0
votes
1answer
27 views

get a tab out of a vector

if I have the first line of my file looking like this NAMES n1 n2 n3 betwen row1 and t1 there are two tabs but there should only be a single tab...the line is in a larger file it is ...
3
votes
3answers
260 views

apt-file regex: escaping a dot

I want to find all packages which provide a shared object containing "ssl" in the file name. The apt-file manpage says: --regexp | -x Treat pattern as a (perl) regular expression. ...
5
votes
3answers
360 views

How to remove domain part of each line from text file containing email addresses

I have a text file with one email address per line. How can I remove the domain part but not the TLD part of each line? In here, we would define TLD to be the last element of the string after the last ...
-4
votes
2answers
39 views

get two files together [duplicate]

how could I get two files together like this file1.txt: ROW 1 3 5 654 56 5 56 65 6 54 4 3345 35 53 3 32 2 1 ROW2 6 65 456 67 687 78 89 657 435 34 534 5 435 5 2 file4.txt: ...
3
votes
4answers
298 views

Bash create custom string

how could in bash a pattern like ROW1 n1 n2 n3 n4 up to 300 be done with some command in bash or also just perl...the delimiter would need to be \t as above
5
votes
6answers
5k views

Grep beginning of line

I have a file with the following contents: (((jfojfojeojfow // hellow_rld (((jfojfojeojfow // hellow_rld How can I extract every line that starts with a parenthesis?
1
vote
1answer
61 views

use of patterns symbol in regular expression

I am new to regex, Can anyone explain for me the patterns: [a-fA-F\d]{30} [\d\w] [-+_~.\d\w] [-\d\w]{0,253}
3
votes
4answers
562 views

What kind of space character is this?

This is pretty weird, using a .txt document sent by a friend using Windows, I believe I have found a weird space character. If I run cat file the character appears as �� Also, I was running if [[ " "...
0
votes
3answers
85 views

Grep for a pattern in line

How can i grep for a specific pattern of numbers like 1000010000000 in a whole file - the line has to have thes numbers at the beginning not somewhere else...
4
votes
2answers
7k views

How to specify a filename while extracting audio using youtube-dl?

I can create an mp3 of a YouTube video with the following command: youtube-dl --extract-audio --audio-format mp3 http://www.youtube.com/watch?v=rtOvBOTyX00 It creates an mp3 with the following ...
-2
votes
2answers
311 views

Name files after split command

there is a large file I split in bash. I am using split -l 20000 -d "job1" "job1" where job 1 is the input file - how can I change the naming of the output so that it produces job1_1,job1_2,...