Sponsored Content
Full Discussion: Pattern matching in BASH
Top Forums Shell Programming and Scripting Pattern matching in BASH Post 302112525 by zoo591 on Wednesday 28th of March 2007 05:47:16 PM
Old 03-28-2007
Question Pattern matching in BASH

i have 255 files in a directory named 000po.k thru 255po.k
and I want to copy all files except 3: exclude 000po.k, 166po.k,168po.k

I know the long way around it copying these files, but am looking for a shorter way of doing this:

my old approach:

# copy 001po.k thru 009po.k to target directory
cp $SRC/0[0-9][1-9]po.k $TGT

# copy 100po.k thru 159po.k
cp $SRC/1[0-5][0-9]po.k $TGT

... etc etc etc ...

my new approach is to exclude the files I don't want to copy, but
this isn't working for me.

cp $SRC/!(000po.k|166po.k|168po.k) $TGT

syntax error near unexpected token `('


TIA for your help.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

bash pattern matching echo *[! '/' ] doesn't work

without using ls, just using echo so purely pattern matching I can say echo */ <-- lists directories but how would I match files? surely something like *!/ or * but neither work ? it seems like there isn't much that I can put in but surely i should be able to put any ascii... (1 Reply)
Discussion started by: james hanley
1 Replies

2. Shell Programming and Scripting

bash script, pattern matching + sum

Hi guys, i have been struggling to achieve the following and therefor looking for some help. I am trying to write something that will summerize the following output from my switches for daily totals. Basicly if $1 $2 $3 doesnt change, we can keep adding up $4. Probably would use a awk print end... (3 Replies)
Discussion started by: Wratholix
3 Replies

3. Shell Programming and Scripting

comment/delete a particular pattern starting from second line of the matching pattern

Hi, I have file 1.txt with following entries as shown: 0152364|134444|10.20.30.40|015236433 0233654|122555|10.20.30.50|023365433 ** ** ** In file 2.txt I have the following entries as shown: 0152364|134444|10.20.30.40|015236433 0233654|122555|10.20.30.50|023365433... (4 Replies)
Discussion started by: imas
4 Replies

4. Shell Programming and Scripting

counting the lines matching a pattern, in between two pattern, and generate a tab

Hi all, I'm looking for some help. I have a file (very long) that is organized like below: >Cluster 0 0 283nt, >01_FRYJ6ZM12HMXZS... at +/99% 1 279nt, >01_FRYJ6ZM12HN12A... at +/99% 2 281nt, >01_FRYJ6ZM12HM4TS... at +/99% 3 283nt, >01_FRYJ6ZM12HM946... at +/99% 4 279nt,... (4 Replies)
Discussion started by: d.chauliac
4 Replies

5. Shell Programming and Scripting

sed - matching pattern one but not pattern two

All, I have the following file: -------------------------------------- # # /etc/pam.d/common-password - password-related modules common to all services # # This file is included from other service-specific PAM config files, # and should contain a list of modules that define the services... (2 Replies)
Discussion started by: RobertBerrie
2 Replies

6. UNIX for Dummies Questions & Answers

Find pattern suffix matching pattern

Hi, I am trying to get a result out of this but fails please help. Have two files /tmp/1 & /tmp/hosts. /tmp/1 IP=123.456.789.01 WAS_HOSTNAME=abcdefgh.was.tb.dsdc /tmp/hosts 123.456.789.01 I want this result in /tmp/hosts if hostname is already there dont want duplicate entry. ... (5 Replies)
Discussion started by: rajeshwebspere
5 Replies

7. Shell Programming and Scripting

Sed: printing lines AFTER pattern matching EXCLUDING the line containing the pattern

'Hi I'm using the following code to extract the lines(and redirect them to a txt file) after the pattern match. But the output is inclusive of the line with pattern match. Which option is to be used to exclude the line containing the pattern? sed -n '/Conn.*User/,$p' > consumers.txt (11 Replies)
Discussion started by: essem
11 Replies

8. Shell Programming and Scripting

PHP - Regex for matching string containing pattern but without pattern itself

The sample file: dept1: user1,user2,user3 dept2: user4,user5,user6 dept3: user7,user8,user9 I want to match by '/^dept2.*/' but don't want to have substring 'dept2:' in output. How to compose such regex? (8 Replies)
Discussion started by: urello
8 Replies

9. Shell Programming and Scripting

Bash pattern matching question

I need to check the condition of a variable before the script continues and it needs to match a specific pattern such as EPS-03-0 or PDF-02-1. The first part is a 3 or 4 letter string followed by a hyphen, then a 01,02 or 03 followed by a hyphen then a 0 or a 1. I know I could check for every... (4 Replies)
Discussion started by: stormcel
4 Replies

10. UNIX for Dummies Questions & Answers

Grep -v lines starting with pattern 1 and not matching pattern 2

Hi all! Thanks for taking the time to view this! I want to grep out all lines of a file that starts with pattern 1 but also does not match with the second pattern. Example: Drink a soda Eat a banana Eat multiple bananas Drink an apple juice Eat an apple Eat multiple apples I... (8 Replies)
Discussion started by: demmel
8 Replies
DRADIO(5)							  DRadio Manuals							 DRADIO(5)

NAME
dradio - Danmarks Radio netradio player configuration file SYNOPSIS
~/.config/dradio/menu.xml DESCRIPTION
The dradio(1) configuration is a simple XML file with a list of menu items. This file should be edited, to reorder, to remove, or to add playlist URL's to fit your preferences. See dradio-config(1) for help to regenerate the configuration. CONFIGURATION FILE FORMAT
<menu> The root element. <item label="LABEL" src="SRC" type="[direct | playlist | rss]" /> A menu item. The LABEL attribute value is the display name of the channel/podcast. The SRC attribute value is the channel/podcast URL. The type attribute determines which kind of URL the SRC points to, and how mplayer must be invoked to play it. If the type is 'direct' no extra mplayer options are applied, if the type is 'playlist' the mplayer -playlist option is applied, if the type is 'rss' it is assumed SRC is a RSS 2.0 podcast URL. FILES
~/.config/dradio/menu.xml The menu configuration file. http://www.dr.dk/netradio/wmp.asp DR netradio direct links page. http://www.dr.dk/Podcast DR podcast direct links page. AUTHOR
Jess Thrysoee <jess@thrysoee.dk> SEE ALSO
dradio(1), dradio-config(1), mplayer(1) DRadio JANUAR 2009 DRADIO(5)
All times are GMT -4. The time now is 07:41 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy