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

-2
votes
1answer
22 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 ...
1
vote
2answers
164 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
45 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
176 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
23 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
135 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
264 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
35 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
243 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
519 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
23 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
511 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
67 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...
2
votes
2answers
417 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
48 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
67 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
79 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
90 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 ...
0
votes
1answer
33 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
49 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
1k 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
216 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
471 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
577 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
153 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
412 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
236 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
355 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
303 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
93 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
125 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 ...
1
vote
1answer
63 views

Command-line perl regex replacement: replacement string contains utf8

Say you have a file named test.txt with the following lines: ಕದಂ.ಬ कदम्ब. Then, suppose you want to replace each dot following a devanagarI unicode character (ie in कदम्ब) with a ।. Then, you might ...
1
vote
1answer
94 views

Find and replace regular expression (matching unicode character class Devanagari) in multiple files

Say you have a file named test.txt with the following lines: ಕದಂಬ कदम्ब Then, suppose you want to replace each devanagarI unicode character (ie in कदम्ब) with a D. Then, you might think that the ...
2
votes
3answers
175 views

How do I extract a single attribute from an XML file?

I'm not really familiar with regex, sed, etc. and a bit lazy to figure it out right this moment, so how do I extract this line: <yweather:astronomy sunrise="6:50 am" sunset="7:06 pm"/> Let me ...
3
votes
3answers
98 views

Move pattern to beginning of line

I am trying to reformat a log file such that date and time appear at the beginning of the line. My logs look like this: blah, blah, blah, Friday, Mar 13,2015 16:59:42 yadi, yadi, yada, Friday, Mar ...
2
votes
3answers
208 views

Remove all text before last space in text file from CLI

I want to remove everything before the last space in a text file from the CLI Example text: 2015-03-02 21:34:15 20480 dump-2015-03-02-21-34.tar The string that should remain is ...
0
votes
1answer
70 views

Excluding hidden files in locate

We have a Ubuntu NAS sharing SMB and Netatalk with some Macs and I often use locate to find my files. Unfortunately since installing Netatalk it has written tons of .AppleDouble cache files to share ...
0
votes
2answers
648 views

unable to install apache2 on precise

Below is the error while running the command: root@mycompanyname:~# apt-get install apache2* Reading package lists... Done Building dependency tree Reading state information... Done E: Unable to ...
-1
votes
2answers
52 views

faced problem in regex

i am having a text file which contain some queries like below. leptop pencil group leptop book gruop buk grop laftop pensil laptop pancil laptop bag bok from this i just want query which start with ...
0
votes
1answer
41 views

Syntax for regex in IF statment

I'm trying to come up with the syntax for a regex in an IF statement, but I'm not quickly having success... Can anyone lend a quick hand please? if [[ "$path/$file" =~ .{txt,doc,docx,xlsx,rtf} ]]; ...
1
vote
1answer
54 views

Color the regular expression in same file

I have a big file and need to look over certain patterns. and also look for another patterns based on first pattern and thus this requires to color the lines which matches the search in the same file. ...
1
vote
3answers
395 views

One liner ffmpeg (or other) to get only resolution?

I'm not really well versed in the command line so hopefully this isn't too stupid of a question. If I run: ffmpeg -i videofile.avi I get an output such as this: ffmpeg version ...
1
vote
1answer
182 views

Why do these regular expressions in grep behave strangely?

I wanted to play a bit with a grep command using regular expressions and find out that they behave differently from what I expected. For example, for a file temp with the following content helloworld ...
-4
votes
3answers
825 views

find all headers file begin with vowels in /usr/include

I need to find all headers from /usr/include that begin with vowels (a,e,i,o,u) Example: acpi.h aclinux.h ah.h ... I don't know how to do it , I tried something with grep but I didn't make it ...
2
votes
3answers
90 views

Regex PDF search?

I am an electronics engineer and I regularly view PDF schematics. Often I encounter the scenario where I would like to search the schematic for a component, e.g. "R1" The problem is that searching ...
0
votes
1answer
26 views

Using grep with regex

I have a regex which works fine for me. I checked it on following site: https://www.regex101.com/ (?<=.log:)[^;]* Unfortunately it doesn't work anymore when I try to use it with grep. I try to ...
0
votes
1answer
38 views

Grep for specfic number format

I have a Unix script, which within has release numbers which are like this (2.19.0.32) Look like IP's but are not as some are like this 2.23.0.06.DBP. I've tried variations of this but comes back ...
4
votes
4answers
2k views

How to find all patterns between two characters?

I'm trying to find all patterns between a pair of double quotes. Let say I have a file with contents look like as following: first matched is "One". the second is here"Two " and here are in second ...
0
votes
0answers
72 views

header_checks in Postfix

I attempted to write a regex for header_checks to filter out To: header, but it is not working. The assumption is: if a header To: does not contain local domain names it will reject the message. ...
4
votes
3answers
434 views

Replace text inside quotes in vim

I have a large sql file and I would like to rename the table name from `feedback` to `comments` but I don't want to replace the word feedback in case any row has that text so I was trying to select it ...