06-25-2013
Quote:
Originally Posted by
Grünspanix
But now I realize: you use the first as anchor character "^" to define, that at the beginning of the line the following expression in '(...)' must follow. I was confused initially as the grymoire docs described the anchor to be used "on the beginning of a line" - and then I wasn't sure where the "line" was in this case. Was it the original "$line" or the splitted parts of the line? Obviously in this case every splitted part is its own "line". Thats why it works. Eventually I understood
![Thumbsup Smilie](https://www.unix.com/images/smilies/thumb.gif)
Correct, perhaps "the beginning of the
string" would be more appropriate.
Quote:
Regarding Perl: yeah, there was the choice between perl or bash scripts and then the thought came "use something which is always available and more down-to-earth" - and the decision fell to default shell scripts.
While it is an interesting learning experience I have previously used some perl and it was way more comfortable. I am not sure the pure shellscripting decision was right after all, especially seeing that perl is installed on most unix machines anyways...sigh, but what can you do.
That's OK, actually. I almost always use only pure shell scripting too, but
Perl makes the string manipulation really, really easy.
Moreover,
Perl is often available even where
bash is not (an old
HP-UX springs to mind
![Smilie Smilie](https://www.unix.com/images/smilies/smile.gif)
).
10 More Discussions You Might Find Interesting
1. Programming
Sir,
I want to check for the repation of a user address in a file i used || as my delimiter and want to check repetaip0n of the address that is mailid and then i have to use IMAP and all.
How can i do this...
I am in linux ...and my file is linux file.
... (5 Replies)
Discussion started by: arunkumar_mca
5 Replies
2. Shell Programming and Scripting
Hi guys,
I need help:
I started receiving automatic emails containing download information. The problem is that these emails are coming in a rich format (I have no control of this) so the important information is buried under a bunch of mumbo-jumbo. To complicated things even further I need to... (10 Replies)
Discussion started by: caprica13
10 Replies
3. UNIX for Advanced & Expert Users
HI....
It's fallow up file ..
#./show.sh click enter button.. i am gettng the fallowup file. its keep on running every time why because there are lots of users working on it.
In that file i want to search pattern between two words
for ex:
SELECT DISTINCT... (7 Replies)
Discussion started by: ksr.test
7 Replies
4. UNIX for Dummies Questions & Answers
Hi,
I am writing a BASH shell script. I would like to count all the files in the CURRENT directory matching a specific pattern. Could someone suggest the best/simplest way to do this. I have thought of these solutions (for simplicity the pattern is all files starting with A):
ls -1 *A | wc -l... (5 Replies)
Discussion started by: msb65
5 Replies
5. UNIX for Advanced & Expert Users
Hi,
I have two files that I need to match patterns with and the second file has comma delimited rows of data that match but I'm having trouble getting a script to work that gives me the match output to these sets :
file 1:
PADG_05255
PADG_06803
PADG_07148
PADG_02849
PADG_02886... (8 Replies)
Discussion started by: greptastic
8 Replies
6. Shell Programming and Scripting
i am not sure what i should be using but would like a simple command that is able to insert a certain block of text that i define or from another text file into a xml file after a certain match is done
for e.g
insert the text
</servlet-mapping>
<!-- beechac added - for epic post-->... (3 Replies)
Discussion started by: cookie23patel
3 Replies
7. UNIX for Dummies Questions & Answers
Hi,
I have following files in my directory:
/TESTDONTDEL> ls -alt
total 14
drwxr-xr-x 2 oracle dba 1024 May 15 06:30 .
-rw-r--r-- 1 oracle dba 40 May 15 06:30 exception.txt
-rw-r--r-- 1 oracle dba 19 May 15 06:22 ful_1234_test1.txt
-rw-r--r-- 1... (2 Replies)
Discussion started by: sagarparadkar
2 Replies
8. Shell Programming and Scripting
Can someone please assist me, I'm trying to get vi to remove all the occurences of the text in a file i.e. "DEVICE=/dev/mt??". The "??" represents a number variable. Is there a globel search and delete command that I can use?
Thank You in Advance. (3 Replies)
Discussion started by: roadrunner
3 Replies
9. UNIX for Dummies Questions & Answers
Hello all,
this is my first and probably not my last question around here. I do hope you can help or at least point me in the right direction.
My question is as follows, I need to find files and possible folders which are not owner = AAA group = BBB with a said location and all sub folders ... (7 Replies)
Discussion started by: kilobyter
7 Replies
10. UNIX for Dummies Questions & Answers
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
wordexp(3C) wordexp(3C)
NAME
wordexp(), wordfree() - perform word expansions
SYNOPSIS
DESCRIPTION
performs word expansions and places the list of expanded words into the structure pointed to by pwordexp.
The words argument is a pointer to a string containing one or more words to be expanded. The expansions are the same as would be performed
by the shell (see sh-posix(1)), if words were the part of a command line representing the arguments to a utility. Therefore, words must
not contain an unquoted newline character or any of the unquoted shell special characters or except in the context of shell command substi-
tution. If words contains an unquoted comment character, it is treated as the beginning of a token that interprets as a comment indicator,
causing the remainder of words to be ignored.
The structure type is defined in the header and includes the following members:
A used to keep count of words matched by words.
A used as a pointer to a list of expanded words.
Also a used to indicate the number of slots to reserve at the beginning of
stores the number of generated words into Each individual field created during field splitting or path name expansion is a separated word
in the list. The words are in order as described in shell word expansions. The first pointer after the last word pointer is a null
pointer. The expansion of special parameters (such as $$ or $*) is unspecified.
It is the caller's responsibility to allocate the storage pointed to by pwordexp. allocates other space as needed, including memory
pointed to by
frees any memory associated with pwordexp from a previous call to
The flags argument is used to control the behavior of The value of flags is the bitwise inclusive OR of zero or more of the following con-
stants, which are defined in
Append words generated to the ones from a previous call to
Make use of If this flag is set, is used to specify how many null pointers to add to the beginning of In other words, points
to null pointers, followed by word pointers, followed by a null pointer.
Fail if command substitution is requested.
The pwordexp argument was passed to a previous successful call to and has not been passed to The result is the same
as if the application had called and then called without
Do not redirect stderr to
Report error on an attempt to expand an undefined shell variable.
The flag can be used to append a new set of words to those generated by a previous call to The following rules apply when two or more calls
to are made with the same value of pwordexp and without intervening calls to
o The first call must not set All subsequent calls must set it.
o All of the calls must set or all must not set it.
o After the second and each subsequent call, points to a list containing the following:
o Zero or more null pointers, as specified by and
o Pointers to the words that were in the list before the call, in the same order as before.
o Pointers to the new words generated by the latest call, in the specified order.
o The count returned in is the total number of words from all of the calls.
o The application can change any of the fields after a call to but if it does, it must reset them to the original value before a
subsequent call, using the same pwordexp value, to or with the or flag.
If words contains an unquoted newline, parentheses, or curly brackets in an inappropriate context, fails, and the number of expanded words
is zero.
Unless is set in flags, redirects stderr to for any utilities executed as a result of command substitution while expanding words. If is
set, writes messages to stderr if syntax errors are detected while expanding words.
If is set, has the same value for each call and the call using a given
RETURN VALUE
Upon successful completion, returns zero; otherwise, it returns a nonzero value defined in to indicate the error:
One of the unquoted characters
parentheses, or braces appears in words in an inappropriate context.
Reference to undefined shell variable when
is set in flags.
Command substitution requested when
was set in flags.
Attempt to allocate memory failed.
Shell syntax error such as unbalanced parentheses
or unterminated string.
Internal error.
If returns the error value and are updated to reflect any words that were successfully expanded. In other cases, they are not modified.
AUTHOR
and were developed by OSF and HP.
SEE ALSO
sh-posix(1), fnmatch(3C), glob(3C), regexp(5), thread_safety(5).
STANDARDS CONFORMANCE
wordexp(3C)