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

3
votes
2answers
46 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 ...
1
vote
2answers
140 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
45 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 ...
0
votes
0answers
44 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
9 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
82 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
216 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: ...
1
vote
2answers
25 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
21 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
72 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
38 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
98 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
90 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
58 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
80 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 = ...
0
votes
1answer
75 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
25 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
20 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
142 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
175 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
199 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 ...
0
votes
3answers
63 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 ...
2
votes
1answer
274 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 ...
0
votes
1answer
25 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
200 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
308 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
38 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
270 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
2k 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
38 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
540 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
77 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...
3
votes
2answers
3k 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
113 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 ...
0
votes
1answer
121 views

mksquashfs not excluding file

I am having issues excluding a specific file from a squashfs. I want to be able to exclude all file types ending with *.db but have had no luck. Whenever I run the mksquashfs command with the ...
2
votes
3answers
328 views

adduser.conf NAME_REGEX is not working

I am trying to set a rule for new users. I changed the /etc/adduser.conf file by adding the line: NAME_REGEX="[A-Z]{1}[a-z]{5,9}$" but after that, the system is not accepting any user.. always ...
3
votes
2answers
126 views

grep regex pattern causes unexpected command behavior

I'm searching for lines with $ and consecutively ' or " through this grep in my terminal: grep "\\$('|\")" -rin folder_path After pressing enter the terminal doesn't think the line is complete so ...
1
vote
1answer
36 views

how to pass single file not list of files

I am running this command while IFS= read -r file;do split -l 20000 -d "$file" "$file";done < file.list.txt now my problem is that this accepts as input a list of files (file.list) which looks ...
2
votes
2answers
53 views

How can I put a cluster lines in numeric order?

How can I convert this: -foo -bar 42 \ randomtext=00 "00" \ -randomtext=00 "00" \ -foo -bar 104 \ randomtext=00 "00" \ -foo -bar 1 \ -randomtext=00 "00" \ To this: ...
1
vote
3answers
3k views

split large file in bash

How can I pass all files in a list.txt which looks like file1_1.txt file1_2.txt file1_3.txt file1_4.txt to the split command (there are other txt files in the dir) and make it return the parts ...
3
votes
2answers
246 views

Regex Conversion

I'm wanting to make a command to edit /etc/default/grub and change the timeout from 10 to 2. Could anyone explain how to do this?
18
votes
5answers
655 views

How can I merge files on a line by line basis?

cat file1 foo ice two cat file2 bar cream hundred Desired output: foobar icecream twohundred I already have a solution involving a for loop with sed using the line number of the files, but in ...
4
votes
4answers
1k views

How can I extract text between parentheses containing a specific word?

How can I convert this: foo (blah) (bar 80) foo (cats) (blat 92) To this: foo bar 80 foo blat 92 I would like to keep all the text that is NOT in parentheses. I only want to extract text ...
5
votes
1answer
206 views

Bash always evaluate Regex as true

In a script, there's these lines #!/bin/bash ... if ! [[ $SCREEN_NAME =~ ^[a-zA-Z0-9_.-]+$ ]]; then echo "The Server title contains invalid symbole. Only a-z A-Z 0-9 - _ . are allowed" exit 1; ...
6
votes
5answers
464 views

How can I edit a range of text between 2 symbols? awk, sed, regex

Using the "*" symbol, (doesn't have to be that one, any special character will do in order to indicate), how can I edit the text from this: *berry straw rasp blue boysen * blahblah blahblah blahblah ...
3
votes
1answer
267 views

How do I use the “^” and “$” symbols with regular expressions in a bash script?

How do I use the "^" and "$" symbols with regular expressions in a bash script? Please give me an example using both symbols.
4
votes
3answers
587 views

Reverse sed's/regexes' pattern-matching priority order

Consider this command: echo "string.with.dots" | sed 's/\(.*\)\.\(.*\)/\1\n\2/' (Matches into a first capturing group any character until the last . and into a second capturing group any character ...
3
votes
4answers
454 views

What is a practical way to list every character used in a file (Bash) (Regex)

How can I turn this: Johnny's penguin, (Tuxie), likes the following foods: French fries, and beef. To this: abcdefghiklnoprstuwFJT',():. (These are the total characters used in the input) ...
0
votes
1answer
117 views

How can I split a line in 2 by words/characters? (Bash) (Regex)

I would like to convert: Hello Hello Hi Hello Hello Hi Hi Hi Hi Hello To: Hello Hello Hi Hello Hello Hi Hi Hi Hi Hello I want to split a single line in 2, by having them have the closest amount ...
0
votes
3answers
241 views

Batch rename, add extra “.” character at position 3 in filename, recursively

I've been struggling to make this work but I am not very good with regex. This is what I tried to do and it didn't work (after 50 minutes, still going on with no visible change): while IFS= read -r ...