01-14-2015
So - you want to ls the files matching the pattern and then remove the portinon matching one char wildcards ?, but keep the more generic wildcard(s) * matches? And you want to keep chars given literally, but remove single chars pre-, postfixed or interspersed in the ?s?
First, you'll have to quote the parameter when calling the script to prevent the shell from expanding it. find . -name "$1" might provide you with the desired file names. Let me think a while for the removal of the name portions.
This User Gave Thanks to RudiC For This Post:
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi all
I want to find a particular file type lets say .abc under /home/oracle/, the file name is start with 'D' and followed by ddmmyyyy date format, the file name should look like this D19092008.abc To my question, how can i perform the searching from the date 19/09/2008 to 29/09/2008. The... (3 Replies)
Discussion started by: coldstarhk
3 Replies
2. UNIX for Dummies Questions & Answers
Hi,
I wanted to delete all the files under a directory "/apps/tmp/" which are two weeks older. But i should not delete the sub-directories and the contents of sub-directories.
I also have searched in forum and found the following command,
find . \( ! -name . -prune \) -mtime +13 -print
... (8 Replies)
Discussion started by: Sheethal
8 Replies
3. UNIX for Dummies Questions & Answers
I have a directory (and many sub dirs beneath) on AIX system, containing thousands of file. I'm looking to get a list of all directory containing "*.pdf" file.
I know basic syntax of find command, but it gives me list of all pdf files, which numbers in thousands. All I need to know is, which... (4 Replies)
Discussion started by: r7p
4 Replies
4. Solaris
Hi,
I'm searching for a pattern 'java' under a directory but it is returning all the files containing 'java', but I want to have only distinct files not all.
please help (2 Replies)
Discussion started by: b.paramanatti
2 Replies
5. Shell Programming and Scripting
Hello ,
Can anyone help me with my below query
I am trying to find a text in directory of files via below command
grep -i cmps_cgs_crs_rfnc_id *
But it returns multiple times same file name i.e if the text found in a file 4 times the file name shown 4 times in the o/p
Is... (1 Reply)
Discussion started by: Pratik4891
1 Replies
6. Shell Programming and Scripting
Hi,
I have two files of the following format
file1
chr1:345-456
chr2:123-456
chr2:455-678
chr3:456-789
chr3:444-555
file2
chr1:345-456
chr2:123-456
chr3:456-789
output (2 Replies)
Discussion started by: jacobs.smith
2 Replies
7. Shell Programming and Scripting
Hi ,
i need to display only one of duplicated values and merged them in one record only when tag started with 3100.2.128.8
3100.2.97.1=192.168.0.12
3100.2.128.8=418/66/03e9/0044801
3100.2.128.8=418/66/03ea/0044601
3100.2.128.8=418/66/03e9/0044801
3100.2.128.8=418/66/03ea/0044601... (5 Replies)
Discussion started by: OTNA
5 Replies
8. UNIX for Advanced & Expert Users
Find all files in the current directory only excluding hidden directories and files.
For the below command, though it's not deleting hidden files.. it is traversing through the hidden directories and listing normal which should be avoided.
`find . \( ! -name ".*" -prune \) -mtime +${n_days}... (7 Replies)
Discussion started by: ksailesh1
7 Replies
9. Shell Programming and Scripting
Platform :Oracle Linux 6.4
Shell : bash
The below file has 7 lines , some of them are duplicates. There are only 3 distinct lines. But why is the uniq command still showing 7 ?
I just want the distinct lines to be returned.
$ cat test.txt
SELECT FC.COORD_SET_ID FROM OM_ORDER_FLOW F, -... (2 Replies)
Discussion started by: kraljic
2 Replies
10. UNIX for Dummies Questions & Answers
Hi
Just want to ask, Is it possible to find a file from a directory up to its sub-directories?
Thanks,
cmarzan (10 Replies)
Discussion started by: cmarzan
10 Replies
LEARN ABOUT DEBIAN
regexp::shellish
Shellish(3pm) User Contributed Perl Documentation Shellish(3pm)
NAME
Regexp::Shellish - Shell-like regular expressions
SYNOPSIS
use Regexp::Shellish qw( :all ) ;
$re = compile_shellish( 'a/c*d' ) ;
## This next one's like 'a*d' except that it'll
## match 'a/d'.
$re = compile_shellish( 'a**d' ) ;
## And here '**' won't match 'a/d', but behaves
## like 'a*d', except for the possibility of high
## cpu time consumption.
$re = compile_shellish( 'a**d', { star_star => 0 } ) ;
## The next two result in identical $re1 and $re2.
## The second is a noop so that Regexp references can
## be easily accomodated.
$re1 = compile_shellish( 'a{b,c}d' ) ;
$re2 = compile_shellish( qr/A(?:a(?:b|c)d)/ ) ;
@matches = shellish_glob( $re, @possibilities ) ;
DESCRIPTION
Provides shell-like regular expressions. The wildcards provided are "?", "*" and "**", where "**" is like "*" but matches "/". See "com-
pile_shellish" for details.
Case sensitivity and constructs like <**>, "(a*b)", and "{a,b,c}" can be disabled.
compile_shellish
Compiles a string containing a 'shellish' regular expression, returning a Regexp reference. Regexp references passed in are passed
through unmolested.
Here are the transformation rules from shellish expression terms to perl regular expression terms:
Shellish Perl RE
======== =======
* [^/]*
? .
** .* ## unless { star_star => 0 }
... .* ## unless { dot_dot_dot => 0 }
( ( ## unless { parens => 0 }
) ) ## unless { parens => 0 }
{a,b,c} (?:a|b|c) ## unless { braces => 0 }
a a ## These are de-escaped and
* * ## passed to quotemeta()
The wildcards treat newlines as normal characters.
Parens group in to $1..$n, since they are passed through unmolested (unless option parens => 0 is passed). This is useless when using
glob_shellish(), though.
The final parameter can be a hash reference containing options:
compile_shellish(
'**',
{
anchors => 0, ## Doesn't put ^ and $ around the
## resulting regexp
case_sensitive => 0, ## Make case insensitive
dot_dot_dot => 0, ## '...' is now just three '.' chars
star_star => 0, ## '**' is now two '*' wildcards
parens => 0, ## '(', ')' are now regular chars
braces => 0, ## '{', '}' are now regular chars
}
) ;
No option affects Regexps passed through.
shellish_glob
Pass a regular expression and a list of possible values, get back a list of matching values.
my @matches = shellish_glob( '*/*', @possibilities ) ;
my @matches = shellish_glob( '*/*', @possibilities, \%options ) ;
AUTHOR
Barrie Slaymaker <barries@slaysys.com>
perl v5.8.8 2002-01-24 Shellish(3pm)