Sponsored Content
Top Forums UNIX for Dummies Questions & Answers grep command & shell procedure's Post 2161 by stevox on Tuesday 24th of April 2001 08:14:51 PM
Old 04-24-2001
hello, i'm trying to pluck words from a list that have exactly 3 occurances of a specified letter. I've come up with this :
grep -i .*$1.*$1.*$1.*
But this also selects words with 4 or more, any tips?

I'm putting this into a shell procedure and want to be able to add a switch before I put the letter to searched in ($1), if you could point me to the correct manual page to read up on that it would be great, I'm using bourne shell.

Thanks in advance
Steve

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How to subtract 2 hours from 'date' in shell ( /bin/sh ) script ?

I write a sh script that zip and copy to tape all files that older then 2 hours. 1. The way I choose is - touch a file with "now - 2 hours", then use fine with '! -newer' 2. Do you have any other idea to do it ? tnx. (1 Reply)
Discussion started by: yairon
1 Replies

2. UNIX for Dummies Questions & Answers

sed 's/~/\^J/g' how to get "^J" on same line as rest of the command.

when ever i type it in it always looks like so echo $file | sed 's/~/\ /g' how can i get it on one line? (6 Replies)
Discussion started by: Optimus_P
6 Replies

3. UNIX for Dummies Questions & Answers

what is the 'whatis' command?

I am kind of new with Unix and I really need some help. Can you please tell me what the 'whatis' command is? and what does it do? Let's say that I have a file which I want to delete, what command will I need to use? If I have a directory that I want to delete all files from what command do... (11 Replies)
Discussion started by: mischiefdemon
11 Replies

4. UNIX for Dummies Questions & Answers

'find' command question

my solaris text talks about the 'find' command... it further goes to talk about an "action" used with the find command. I am completely confused as to what the {} do with the find comand. the explanation is this: "A set of braces, {}, delimits where the file name is passed to the command from... (2 Replies)
Discussion started by: xyyz
2 Replies

5. Shell Programming and Scripting

Clearify what it means under 'WHAT' when hit the 'w'-command

I wonder how I shall read the result below, especially 'what' shown below. The result was shown when I entered 'w'. E.g what is TOP? What is gosh ( what does selmgr mean?)? login@ idle JCPU PCPU what 6:15am 7:04 39 39 TOP 6:34am 6:45 45 45 TOP 6:41am ... (1 Reply)
Discussion started by: Aelgen
1 Replies

6. UNIX for Dummies Questions & Answers

What is with the '&'.

Hi Gurus, I would appreciate if someone could enlighten this newbie as to how significant the '&' is to unix. Currently I am getting around to writing a script which has to deal with a lot of these ampersands either as starting chars or between chars. Please find below the simpliest way that I... (4 Replies)
Discussion started by: buRst
4 Replies

7. Shell Programming and Scripting

grep doesn't work within shell script?

I am trying to run the following code from a script file but it complains that syntax of (both instances of) grep is wrong. When I copy and paste it to the terminal, it is OK. Any idea what the problem might be? set i = `grep -c #define flags.h` while ($i>20) @ i-- my func (`cat... (4 Replies)
Discussion started by: barisgultekin
4 Replies

8. UNIX for Dummies Questions & Answers

VI 'go to position #' command

I apologize is this is somewhere else but I did look.... Is there a command to goto position # x within the VI editor? I've seen where you can search for a particular char string but I need to go to position 200 within a record (tired of counting positions)...:) Thanks in advance... (2 Replies)
Discussion started by: hedrict
2 Replies

9. UNIX for Dummies Questions & Answers

Grep char count & pipe to sed command

Hi I am having a 'grep' headache Here is the contents of my file: (PBZ,CP,(((ME,PBZ,BtM),ON),((ME,((PBZ,DG),(CW9,PG11))),CW9,TS2,RT1))) I would like to count out how many times 'PBZ' occurs and then place that number in the line above 3... (8 Replies)
Discussion started by: cavanac2
8 Replies

10. Shell Programming and Scripting

applescript & grep - sed command

I'm new using Unix commands in applescript. The following script you choose different folders with PDfs, get file count of PDfs on chosen folders, & write the results in text file. set target_folder to choose folder with prompt "Choose target folders containing only PDFs to count files" with... (0 Replies)
Discussion started by: nellbern
0 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)
All times are GMT -4. The time now is 03:33 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy