Sponsored Content
Top Forums Shell Programming and Scripting Global Pattern - exclude directories Post 302843232 by vino_hymi on Monday 12th of August 2013 11:51:59 AM
Old 08-12-2013
Global Pattern - exclude directories

All,

I am trying delete folder by adding pattern not to delete certain folders. But i struck with error.

When i use below command from command line, it works fine.

shopt -s extglob
rm -rf !(test1|test2|test3)


But when i use the same in shell script, i get the below error.

syntax error near unexpected token `('

Any help?
 

9 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

GNUTAR exclude directories

Hi, Can anyone help me with the following: I want to make a backup from my (AIX) system. But I don't want to backup a couple of temp-directories. I tried it with the X-option, but that didn't work. I hope that someone can help me. Thanks in advance. Corine (6 Replies)
Discussion started by: TheBlueLady
6 Replies

2. UNIX for Dummies Questions & Answers

find command to exclude directories

Howdy I have this directory structure ... eep eepaptest eepfatest eepgltest eep.old eeppoptest ehf ehfaptest ehfgltest ehp ehpgltest I want to find files in these directories, but I want to exclude eep, ehf & ehp. Cany anyone help with the correct command ?? (1 Reply)
Discussion started by: SmurfGGM
1 Replies

3. Shell Programming and Scripting

Find but exclude directories

Hello, I have a line in my script to find the files changed in the last 24 hours. It is as below: find /home/hary -type f -mtime -1 I now want to exclude a directory named "/home/hary/temp/cache" from the above find command. How do I add it to my script? Any help is appreciated. ... (9 Replies)
Discussion started by: tadi18
9 Replies

4. Shell Programming and Scripting

Help - Find command to exclude sub-directories

Hi Forum. I'm trying to write a script that finds and deletes files that are older than 300 days. The script will read a table that contains the following 3 columns: 1st col: “Y” means sub-directory scan; "N" means no subdirectory scan 2nd col: sub-directory location 3rd col: File prefix... (7 Replies)
Discussion started by: pchang
7 Replies

5. Shell Programming and Scripting

How to exclude the empty directories

Hi., I have a script, in which I am processing a files present in the directory types. ls -lrt | grep ^d | grep Dir_type | awk -f '{print $9}' |\ while read dir_name; do #operations done where Dir_type is the pattern in which directories get created. How to filter out empty... (2 Replies)
Discussion started by: IND123
2 Replies

6. Shell Programming and Scripting

Perl exclude directories in command line

Hi, I use find command to list all the files in a directory and its sub-directories, but the problem is to exclude certain directories during search. Can i give the directory names in command line to skip them and search rest of the directories? For example i have directories: test ../test1... (1 Reply)
Discussion started by: nmattam
1 Replies

7. Programming

Using sql like to choose a pattern and exclude a pattern

Hi, I am writing an sql query in which i have to choose only that url that are from particular host but are not zip files. something like: select * from mytable where url like '%myhost%' and url not like '%zip%' Is there a simple way to combine these two condition into one? (3 Replies)
Discussion started by: vickylife
3 Replies

8. AIX

Exclude Directories in my tar command

Hi, im having some issues after i execute the next command: tar -cvf /varios/restore/test.tar -X /jfma/test1/excludefile /jfma | gzip -c > /varios/restore/test.tar.gz this creates the desired "test.tar.gz" file, but whe i try to open it it says "tar: 0511-164 There is a media read or write... (6 Replies)
Discussion started by: blacksteel1988
6 Replies

9. Shell Programming and Scripting

Exclude directories in FIND command

Can you please help tweak the below command to exclude all directories with the name "logs" and "tmp" find . -type f \( ! -name "*.tar*" ! -name "*.bkp*" \) -exec /usr/xpg4/bin/grep -i "user_1" /dev/null {} + >result.out bash-3.2$ uname -a SunOS mymac 5.10 Generic_150400-26 sun4v sparc sun4v... (9 Replies)
Discussion started by: mohtashims
9 Replies
MARK(1) 							     [nmh-1.5]								   MARK(1)

NAME
mark - manipulate message sequences SYNOPSIS
mark [+folder] [msgs] [-sequence name ...] [-add | -delete] [-list] [-public | -nopublic] [-zero | -nozero] [-version] [-help] DESCRIPTION
The mark command manipulates message sequences by adding or deleting message numbers from folder-specific message sequences, or by listing those sequences and messages. A message sequence is a keyword, just like one of the "reserved" message names, such as "first" or "next". Unlike the "reserved" message names, which have a fixed semantics on a per-folder basis, the semantics of a message sequence may be defined, modified, and removed by the user. Message sequences are folder-specific, e.g., the sequence name "seen" in the context of folder "+inbox" need not have any relation whatsoever to the sequence of the same name in a folder of a different name. Three action switches direct the operation of mark. These switches are mutually exclusive: the last occurrence of any of them overrides any previous occurrence of the other two. The -add switch tells mark to add messages to sequences or to create a new sequence. For each sequence named via the -sequence name argu- ment (which must occur at least once) the messages named via msgs (which defaults to "cur" if no msgs are given), are added to the sequence. The messages to be added need not be absent from the sequence. If the -zero switch is specified, the sequence will be emptied prior to adding the messages. Hence, -add -zero means that each sequence should be initialized to the indicated messages, while -add -nozero means that each sequence should be appended to by the indicated messages. The -delete switch tells mark to delete messages from sequences, and is the dual of -add. For each of the named sequences, the named mes- sages are removed from the sequence. These messages need not be already present in the sequence. If the -zero switch is specified, then all messages in the folder are added to the sequence (first creating the sequence, if necessary) before removing the messages. Hence, -delete -zero means that each sequence should contain all messages except those indicated, while -delete -nozero means that only the indi- cated messages should be removed from each sequence. As expected, the command "mark -sequence foo -delete all" deletes the sequence "foo" from the current folder. When creating or modifying sequences, you can specify the switches -public or -nopublic to force the new or modified sequences to be "pub- lic" or "private". The switch -public indicates that the sequences should be made "public". These sequences will then be readable by all nmh users with permission to read the relevant folders. In contrast, the -nopublic switch indicates that the sequences should be made "private", and will only be accessible by you. If neither of these switches is specified, then existing sequences will maintain their cur- rent status, and new sequences will default to "public" if you have write permission for the relevant folder. Check the mh-sequence(5) man page for more details about the difference between "public" and "private" sequences. The -list switch tells mark to list both the sequences defined for the folder and the messages associated with those sequences. Mark will list the name of each sequence given by -sequence name and the messages associated with that sequence. If the sequence is private, this will also be indicated. If no sequence is specified by the -sequence switch, then all sequences for this folder will be listed. The -zero switch does not affect the operation of -list. The current restrictions on sequences are: o The name used to denote a message sequence must consist of an alphabetic character followed by zero or more alphanumeric characters, and cannot be one of the (reserved) message names "new", "first", "last", "all", "next", or "prev". o Only a certain number of sequences may be defined for a given folder. This number is usually limited to 27 (11 on small systems). (The internal implementation relies on bitmasks, with some bits set aside for internal use.) o Message ranges with user-defined sequence names are restricted to the form "name:n", "name:+n", or "name:-n", and refer to the first or last `n' messages of the sequence `name', respectively. Constructs of the form "name1-name2" are forbidden for user defined sequences. FILES
$HOME/.mh_profile The user profile PROFILE COMPONENTS
Path: To determine the user's nmh directory Current-Folder: To find the default current folder SEE ALSO
flist(1), pick(1), mh-sequence(5) DEFAULTS
`+folder' defaults to the current folder `-add' if -sequence is specified, -list otherwise `msgs' defaults to cur (or all if -list is specified) `-nozero' CONTEXT
If a folder is given, it will become the current folder. HELPFUL HINTS
Use flist to find folders with a given sequence, and "pick sequence -list" to enumerate those messages in the sequence (such as for use by a shell script). MH.6.8 11 June 2012 MARK(1)
All times are GMT -4. The time now is 06:53 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy