The tag has no usage guidance.

learn more… | top users | synonyms

18
votes
1answer
469 views

Why bracket a single letter in a grep regex?

I've seen several instances where people are doing this: grep [f]oobar But I don't understand why that is preferable to grep foobar
6
votes
3answers
14k views

How to get all running process ids only?

I know that ps ax returns the pids 1 ? Ss 0:01 /sbin/init 2 ? S< 0:00 [kthreadd] 3 ? S< 0:00 [migration/0] All I need is to clean those strings, but I ...
6
votes
2answers
9k views

Apache 2: Negative FilesMatch / FilesNotMatch

If I want to apply a rule to only some files in apache2.conf, I can use <FilesMatch>. For example: <FilesMatch ".(gif|jpg|jpeg|png|mpg|avi)$"> deny from env=hotlink </FilesMatch&...
5
votes
1answer
8k views

Powershell 2: How to strip a specific character from a body of ASCII text

I am trying to strip odd characters from strings using PowerShell. I used the following output to attempt to learn on my own: get-help about_regular_expressions I am trying to take a string that is ...
4
votes
2answers
833 views

Shell scripting and regex: Which one is better to match numbers, [[:digit:]] or [0-9]?

As the title suggests, which one is better to match numbers, [[:digit:]] or [0-9]? I'm using the bash shell Thanks :)
4
votes
1answer
185 views

Apache MatchRedirect exception regex

I want to redirect any URL that is Https and hasn't start with "system_" to the same URL with http. for exapmle for this url : https://exsite.tld/some/thing/that/not/start/with/pattern to : http:/...
3
votes
4answers
1k views

Extract repository name from GitHub url in bash

Given ANY GitHub repository url string like: git://github.com/some-user/my-repo.git or git@github.com:some-user/my-repo.git or https://github.com/some-user/my-repo.git What is the best way in ...
3
votes
1answer
211 views

nginx - which way is better to redirect and why

I want to redirect from www.mydomain.com to domain.com in nginx. I search the internet and found two ways: First way server { listen 80; server_name www.domain.com; ...
3
votes
2answers
148 views

Case insensitive exiqgrep?

My mail queue is currently full of bounce messages for the same domain, but in mixed case. I tried using exiqgrep to filter these mails from my queue, but it seems that the command is case sensitive. ...
3
votes
1answer
4k views

inotifywait usage and exclude

I want to monitor special path to any event of create or modified files recursively in it via inotifywait but I don't know what's my problem is. I have some folders that I want to exclude. watchpath ...
3
votes
1answer
976 views

Powershell deleting files with regular expressions

I have several thousand files of different revisions in a folder. ACZ002-0.p ACZ002-1.p ACZ002-2.p ACZ051-0.p ACZ051-1.p ... The revision is always the last digit before the dot. I need to preserve ...
2
votes
2answers
15k views

grep to find files that contain a string greater than x characters long?

Is it possible to locate files in a directory that have strings (with no spaces) longer than x length?
2
votes
2answers
2k views

How to find files that don't contain a given search string

I have a command that finds all the PDF files that contain the string "Font" find /Users/me/PDFFiles/ -type f -name "*.pdf" -exec grep -H 'Font' '{}' ';' How can I change this command such that it ...
2
votes
2answers
7k views

nginx simple regex location

I need to set a location param in nginx if the first 5 digits of the url are numbers. site.com/12345/ or site.com/12345 But I can't for the life of me seem to get the correct regular expression. ...
2
votes
3answers
2k views

Regular Expression matching in ssh config

I have a bunch of servers with the names srv1.domain.com, srv2.domain.com, ..., srv50.domain.com I want to be able to connect to these servers by ssh srv1 I don't want to put 50 configuration ...
2
votes
1answer
8k views

use sed in shell script to replace IP Address in a file

I have a script that finds a string in a file replaces it with a new string. $ sed -i 's/$old_string'/'$new_string'/g' $FILENAME Now I need the condition to be a regular expression that also check ...
2
votes
2answers
170 views

Display nth instance of grepped pattern

So here's my problem. I have an issue with a .csv file (Current.csv) in that there are commas randomly place throughout the data, so awk-ing the file doesn't give me constant column numbers for a ...
2
votes
2answers
65 views

Get Apache2.2 to hide Microsoft documents that are being edited?

I have a htdocs directory where I am serving a few Microsoft Word documents. When someone is editing a document, the name of the document changes to look like something like this: "~$my_document.doc"...
2
votes
1answer
2k views

Postfix setting reply-to field to sender

I would like to set the reply-to field to the sender of the mail if the recipient matches some addresses. I know I could do a regular expression like this to do this /^(To|Cc):.*foo@bar.com/ PREPEND ...
2
votes
1answer
2k views

Install yum packages based on regular expression

I would like to install a batch of openoffice.org-* packages from the yum repository. The catch is that I want to exclude the dozens of openoffice.org-langpack* files when I do it. I also don't want ...
2
votes
1answer
158 views

Regular expressions and .htaccess - need help with understanding

I understand .htaccess and mod_rewrite on a fairly basic level, and have just started learning ForceType and SetHandler directives. This is my .htaccess file for my domain, testsite1.localhost (only ...
2
votes
1answer
1k views

rsync certain files, excluding the rest, ignoring .svn/ directory, recursively

I'm using rsync to copy some files from a share to another. Recursively, I need to: Delete files at destination that were removed from the origin Only sync php and js files Exclude every other file ...
1
vote
1answer
107 views

Regular expressions in GREP [closed]

I have an .xml file. The tags inside are: <Info>Product</Info> Now, I have 20 000 tags like this in the file. One tag however, starts properly but it is missing a proper closing tag. ...
1
vote
2answers
143 views

Need help with grep urgently to comply with subpoena request

I am not a system administrator but I run a little website and today I have received a subpoena request from police, in order to comply I need to extract IP addresses from our server logs for needed ...
1
vote
2answers
3k views

PowerShell Regex for validating DOMAIN\username

I have the following regexp for validating Windows usernames in a PowerShell script. $fqusername -imatch '^\w+[\\]\w+$' This works fine in my own environment, but I am planning on releasing it for ...
1
vote
1answer
73 views

Adding Curly Braces to Map block in nginx

I am having a problem trying to get the following configuration to work. Every time I run the config test I get a failed pass. To start off let me show you a working configuration location / { ...
1
vote
2answers
2k views

RegEx Match URL Pattern

I'm trying to come up with a regex pattern that will match any domains in this format: example.com but not this: subdomain.example.com Currently it needs to only cover the main TLDs (com, net, org)...
1
vote
2answers
216 views

Using a regular expression (perl?) on a MySQL DB

I have a MYSQL DB and I need to do some text manipulation on one of the fields. This is a one-off, not an ongoing process. The built in MySQL text manipulation functions will be a nightmare to do ...
1
vote
1answer
354 views

Postfix header checks

How can I write regex for postfix header check to reject all the mails with X-Source-Dir having abc/def? Is this OK? /^X-Source-Dir:\s(.*abc\/def.*)/ REJECT due to spam: Thanks a lot Ladadadada:)...
1
vote
2answers
2k views

Watchguard Firewall WebBlocker Regular Expression for Multiple Domains?

I'm pretty sure this is really a regex question, so you can skip to REGEX QUESTION if you want to skip the background. Our primary firewall is a Watchguard X750e running Fireware XTM v11.2. We're ...
1
vote
1answer
33 views

Firewall blocking files using Reg_Ex needs to be adjusted

We have security in our firewall to prevent SQL-Injection from destroying any of our content: Name Type Context Severity Pattern Configure CS:select_into signature http-url critical .*\[...
1
vote
1answer
61 views

How can I add values to structured data with rsyslog?

Our logs are sent from our applications to rsyslog running on the same host. Rsyslog then forwards the messages to Sumo Logic. We need to add some metadata to our log messages in the structured data ...
1
vote
2answers
125 views

Regular expression in not working in dnsmasq config

I have dnsmasq version 2.66 installed on CentOS. As per release notes, dnsmasq supports regular expressions starting 2.60 I have following enty in my config file: address=/:clients[0-9]*\.google\....
1
vote
1answer
50 views

Exchange 2013 RegEx transport rule

I am looking to create some transport rules for outgoing email based upon AD properties. eg. Phone: 123-456-7890 Where the actual inserted code looks like "Phone: %%PhoneNumber%%", retrieving the ...
1
vote
1answer
59 views

How to using sed to change the last character from a match line

How to using sed to change the last character from a match line ? Exemple: /etc/network/interfaces auto eth0 iface eth0 inet static address 150.0.3.50 netmask 255.255.255.0 ...
1
vote
1answer
357 views

htaccess rule for url not ending with certain words

I need to rewrite few urls if those url not ending with certain words. For example, i need to rewrite following url /category1/subcategory1/aproduct-url-title to /category1/fixedword/aproduct-url-...
1
vote
1answer
240 views

SetEnvIfNoCase directive match ip failing

I'm trying to set some specific headers based on the client IP address via an Apache reverse proxy. I try to use SetEnvIfNoCase/SetEnvIf but I somehow fail to write a correct regular expression :( ...
1
vote
1answer
125 views

Problematic Mail Sieve rules

I need top classify my incomming emails using this three rules: if the email was send to any @somedomain.tld, then copy that email to "somedomain_tld" if the email was send to any other @*.tld , ...
1
vote
3answers
305 views

Getting different values of particular variable from a file in UNIX

I have a file which I'd like to parse to extract certain values from it. I don't know what command and syntax I should use (maybe sed?). Below are 2 sample lines which I might expect to find in the ...
1
vote
1answer
163 views

Nginx Config Location Regex With Language Code In Url

Trying to achieve constant language code in url's 1st segment with nginx regex location configuration and could not find the correct syntax. Necessary result: example.com stays example.com example....
1
vote
0answers
445 views

How to specify a scenario wildcard in Zabbix expression

I'm using Zabbix 2.0 am wondering how to use a wildcard or regular expression for a scenario name of a trigger? For example, I have the following trigger: MyHost:web.test.fail[<scenario>].avg(#...
1
vote
0answers
217 views

Nginx - Adding a trailing slash to urls on HTTPS

I am using the below regex to add a trailing slash to any url that doesn't have a railing slash or ends ends with .. rewrite ^([^.]*[^/])$ $1/ permanent; This works fine for http, but when I use ...
0
votes
1answer
3k views

nginx httpMapModule regex variables

The HttpMapModule documentation states that: Since 1.0.4, case insensitive regular expressions can be used by prefixing the pattern with ~*. And gives the example: map $uri $myvalue { /aa ...
0
votes
2answers
2k views

Use regular expression in definition of virtualhost

I have to define about 100 subdomain virtualhost entries in server config file . I want to know if there is any way to do it with regular expression to increase codes in apache config file?
0
votes
1answer
548 views

Redirect a url to a different server

I'm looking for a way to redirect any url I visit on my computer (Mac), say www.example1.com/a/b/[\d]+, to another url www.example2.com/a/[\d]+. I don't want this to be on the IP level, just for that ...
0
votes
3answers
589 views

grep out unique senders from a huge list of emails

I just found a huge list of emails under my user account in Centos /home/user/mail/new I opened some of them and noticed they were sent from a particular cron job. From address is root@hostname.com. ...
0
votes
4answers
5k views

non greedy grep command on ubuntu?

I'm building a script which filters out all our translatables from our template system. the problem i'm facing is the occasion where 2 translatables are on one line. These are 2 example lines from a ...
0
votes
1answer
75 views

Manage several sub domains with nginx

I like to handle different sub domains in my Nginx server, this is my config file (partially) server { listen 80 default_server; listen ...
0
votes
2answers
663 views

How to clear contents of all the files using find command

Is there an easy step to clear contents of all ".log" file using find command. Currently i am using "echo -n > filename.log" i have tried echo -n > /var/application-logs/*.log but it is not working.....
0
votes
1answer
158 views

Help with regexp in <Files> tag of .htaccess

For poorly configured Apache servers you can have to do something like this to deny access to the .htaccess file: <Files .htaccess> order allow,deny deny from all </Files> I would like ...