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
votes
2answers
27 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
0answers
13 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
36 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
43 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
25 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
38 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
278 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
3answers
169 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?
17
votes
5answers
376 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
220 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
123 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
295 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 ...
2
votes
1answer
148 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
131 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
257 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
62 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
68 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
38 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
63 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
96 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
71 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
143 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
55 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
141 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
48 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
32 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
47 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
168 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
169 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
740 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
73 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
21 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
37 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
1k 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
42 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
375 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 ...
1
vote
4answers
436 views

extract text from a file using terminal?

I want to process the body of text and extract an integer from a specific position in the text, but I'm not sure how to describe that 'particular position'. Regular expressions really confuse me. I ...
1
vote
2answers
424 views

Exclude directories from inotifywait

Doing an inotifywait to watch a directory, and trying to exclude all subdirectories from being watched while not excluding the files. inotifywait -r -q --exclude <pattern> dir/ What to put in ...
2
votes
1answer
76 views

Vi syntax highlighting for words followed by a parenthesis

I want to change the color of a keyword that is followed by a left parenthesis in a .R file. For instance, when I type length(), I want the word length to be highlighted (and not the parentheses), ...
2
votes
1answer
851 views

Fail2Ban Regex SSH Will not Match Auth.Log - Searched Everywhere for a Solution

Im trying to get Fail2Ban to work with the SSHD Config provided. When i run fail2ban-regex /var/log/auth.log /etc/fail2ban/filter.d/sshd.conf The Output is as follows ...
0
votes
1answer
59 views

Explain in details egrep line

Hi i found in the internet egrep line. The line founds the longest line in the text. But i dont understand specific elements. Maybe someone could explain me all line? Here it is: egrep -n "^.{$(wc -L ...
2
votes
2answers
87 views

Change text in many files

I have a C++ project, where each file has at its beginning some lines of license. Now, that my license have changed, I need to update it in each file. I don't want to do it manually, since its lots of ...
1
vote
2answers
659 views

How do I use regex to remove all punctuation and symbols? [closed]

I'm using Python 2.7 regex. I need to remove all symbols, punctuation, numbers and whitespace from strings in different languages. For example, these two strings: the following characters: ...
0
votes
1answer
99 views

How can I uninstall only one of the versions of Libre Office?

I have both versions of Libre Office installed - 4.3 and the default: dpkg --get-selections | grep -v deinstall | grep libreoffice shows libreoffice-avmedia-backend-gstreamer libreoffice-base-core ...
5
votes
1answer
208 views

How to rename the set of files with pattern

I have files which has name as following: P50_FR_8_q2_scrolls.csv Here the value 50 and 8 needs renaming & The results should be something like: P21_FR_3_q2_scrolls.csv I tired few ...
1
vote
1answer
547 views

Undo apt-get remove --purge

I wanted a fresh install of Python and ran sudo apt-get remove --purge python. Apparently it has killed almost everything I had installed in my system. Looking at the history.log I guess I could ...
1
vote
1answer
122 views

Ubuntu rename command regex not working

I'm trying to use the rename command to rename a bunch of images in a folder. I have this list of images, image.php?x=10 image.php?x=25 image.php?x=50 image.php?x=75 I'm trying to rename them to ...
0
votes
3answers
67 views

Batch Rename Using Regex but Mainaining Some Substring

I made a lot of research before I put this question. I found a different links to do batch rename using regex like this and other similars: *Pattern based, batch file rename in terminal My problem ...
3
votes
1answer
142 views

What happens if we add a dot at the end of sudo `apt-get autoremove`

sudo apt-get autoremove . OUTPUT: WARNING: The following essential packages will be removed. This should NOT be done unless you know exactly what you are doing! apt libapt-pkg4.12 (due to apt) libc6 ...
4
votes
6answers
343 views

Bash script programming: how to match pattern in string?

How I can get this whole value 7I45432ZX from below lines: PW*3434*453*256*PE*UB PO*00*NE*7I4543 2ZX**20140617 PW*3434*453*256*PE*UB PO*00*NE*7I4543 2ZX**20140617 This is the code I tried: grep ...