When to use grep in HP UX version 2?

When to use grep in HP UX version 2?

Hewlett-Packard Company – 2 – HP-UX 11i Version 2: August 2003 grep (1) grep (1) -w Select only those lines containing matches that form whole words. The test is that the matching substring must either be at the beginning of the line, or preceded by a nonword constituent character.

What kind of REGEXP is used in grep?

Normally, each line found is copied to the standard output. grep supports the Basic Regular Expression syntax (see regexp (5) ). The -E option ( egrep) supports Extended Regular Expression (ERE) syntax (see regexp (5) ).

What do you need to know about grep command?

DESCRIPTION [Toc] [Back] The grep command searches the input text files (standard input default) for lines matching a pattern. Normally, each line found is copied to the standard output. grep supports the Basic Regular Expression syntax (see regexp (5) ).

How to force grep to print file names?

To force grep to print file names, add a second argument to the grep command portion of the command line: find . -type f -print |xargs grep xyz /dev/null In this form, the first file name is that produced by find, and the second file name is the null file. WARNINGS [Toc] [Back] (XPG4 only.)

Is there an alternative to grep-Unix for scripting?

Hi All, We have few scripts where we are using grep -w option to do exact matching of the pattern. This works fine on most of our servers. But I have encounter a very old HP-UX System (HP-UX B.11.00) where grep -w option is not available. This is causing my scripts to fail. I need to change… 3. Shell Programming and Scripting

When to use xargs or only exec in HP-UX?

If your version of HP-UX is too old, you might have only -exec … \\; and not -exec … +. The ; version calls the command on one file at a time, which is a bit slower. If your file names don’t contain \\”‘ or whitespace, then you can use xargs without the -0 option.

How to find a file in HP-UX?

If your version of HP-UX is recent enough, you can call find with the -exec … + action. This action does the same job as xargs (call a command on multiple matching files at once, without overflowing the command line length limit), but in a reliable way for any file name.

How to use for Ksh for loops in shell?

Let us see how to use for ksh for loops. The syntax is as follows: Here is sample shell script to print welcome message 5 times: 1 2 3 4 5 is argument list. It can be any list of words, strings, or numbers. We can also use a shell command or shell metacharacter.

How to run Unix for Loop 1 to 100 numbers?

I want to run a Unix command 100 times using a for loop from 1 to 100. Can you tell me how to take a block of numbers in a loop under KSH or BASH shell?

How to start a KSh for loop in Korn?

If above failed to work try the seq command as command substitution in a Korn shell: You can also use variables to define the item list. They will be checked ONLY ONCE, when you start the loop. #!/bin/ksh files = “/etc/passwd /etc/group /etc/hosts” for f in $files; do if [ ! -f $f ] then echo “$f file missing!”