Questions tagged [pattern-matching]

25 questions
4
votes
4 answers

How can I specify a shell pattern that excludes certain files?

For instance, I want to remove all the files in a directory except for the .tar file from whence they came. I could do something like: find . -maxdepth 0 | grep -v '.tar$' | xargs rm -f but is there a way to do is just using rm and shell pattern…
Jared Oberhaus
  • 596
  • 6
  • 14
3
votes
1 answer

htaccess email regex

I am trying to write a patter in such a way that this link : http://www.mysite.com/link/go/emailadress@gmail.com is interpreted like this : http://www.mysite.com/process.php?email=emailadress@gmail.com But i dont know how to write. I tryied this but…
pollux1er
  • 131
  • 6
3
votes
3 answers

How to delete everything except .svn directories?

I have quite complex directory tree. There are many subdirectories, in those subdirectories beside other files and directories are ".svn" directories. Now, under linux I want to delete all files and directories except the .svn directories. I found…
Arek
  • 155
  • 4
  • 9
3
votes
1 answer

makefile shell pattern expansion: how to?

I have found an interesting "feature" of make DIR_INPUT=/test test: # testing date (it should be yesterday) test ! -z "${DATE}" ls -lad ${DIR_INPUT}/{a,c} but it seems to work in a strange way: PROMPT# make test # testing…
asdmin
  • 2,020
  • 16
  • 28
2
votes
2 answers

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 particular type of information I'm looking for. …
user121351
2
votes
2 answers

How to find .h,.c and .cc files under current directory in linux?

find . -name "*.[hc]|*.cc" The above doesn't work,why? UPDATE How do I find these 3 kinds of files with a single pattern?
kernel
  • 8,211
  • 5
  • 18
  • 14
1
vote
2 answers

Nginx location match multiple extensions unless path starts with specific word

How can I write a location block that matches any path ending in the following extensions: jpg|jpeg|gif|css|png|js|ico|json|xml|txt|html Unless the path starts with "/rails" (eg: /rails/randomstring/image.png)? I currently have this basic…
Felipe Zavan
  • 121
  • 1
  • 5
1
vote
1 answer

RewriteCond not matching on my IP when matching on %{REMOTE_ADDR}

I want a mod_rewrite rule not to be executed when traffic is hitting the web-server from internal network. The web server is an apache 2.2 The following RewriteCond is meant to guard the rewrite rule. RewriteCond %{REMOTE_ADDR}…
noamik
  • 163
  • 1
  • 2
  • 10
1
vote
2 answers

finding a group of string common in two files

I have used diff command in past.I faced a situation to which I did not had a clue here are some text strings (which can be stored in a…
Registered User
  • 1,453
  • 5
  • 18
  • 37
1
vote
4 answers

How to do a text match in bash

I'm trying to find a nice way of checking some text in order to set a variable. For instance to perform the logic: 'if the version string is 1.x then set a flag'. One way of doing this is: versionFlag="0" if grep -q "^1.*" versionfile; then …
the_mandrill
  • 165
  • 5
1
vote
0 answers

Multiple negative lookbehind

I have this code: location ~* (/.*)?(?
SuperTony
  • 11
  • 1
0
votes
0 answers

Apache RewriteRule, transfer string match into query string parameter

Our website has been redeveloped, and I have been asked to ensure that the previous form of certain URIs are redirected to the new form, so that existing links, bookmarks, etc, don't break. The previous URIs were of the form /people/show/person/123…
0
votes
0 answers

Nginx location block with regex won't match URL

This is my server block. server { set $auth_header 'Bearer my_token'; listen 80; server_name my.domain.com; location ~ "(/d\-solo/[a-zA-Z]{8,10}/.+\?.+)" { proxy_pass http://localhost:3000/$1; …
Magnus
  • 255
  • 1
  • 2
  • 7
0
votes
2 answers

Count instances of a pattern's match in a real-time log file, in a specific time frame, using PowerShell?

I've to intercept a pattern in a log file and, when this pattern is matched for 5 times in 5 minutes, send an alert... I've wrote this lines, but I'm stuck... I don't know how to handle the time frame... Can you help me please? Roberto. $count =…
ilRobby
  • 1
  • 3
0
votes
2 answers

In Nginx config, how to limit regex matching?

In the nginx config file for my server, I have written the following location block: location ~ /page/(?!(3/?|5/?|6/?|8/?)) { return 301 https://anothersite.com/page$is_args$args; } With this, I'm trying to redirect all /page/ EXCEPT the…
vascaino
  • 1
  • 2
1
2