Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Execute a shell script using regular expressions Post 302171380 by jim mcnamara on Thursday 28th of February 2008 10:20:53 AM
Old 02-28-2008
I don't understand your requirement, but here is a link to a decent tutorial for regex:
Regular Expression Tutorial - Learn How to Use Regular Expressions

If you need to know how to use regex, consider reading:

Jeffery Friedl 'Mastering Regular Expressions'
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Regular Expressions in shell scripts <yawn>

Quite possibly a simple problem who's answer is evading me: I am trying to write a sh shell script, part of which is *logically* trying to do the following: if ]; then ... fi if ]; then ... else ... fi Where the 1st condition is looking for a hostname passed as $1, the second... (3 Replies)
Discussion started by: sam_pointer
3 Replies

2. Shell Programming and Scripting

Regular Expressions

I'm trying to parse RichText to XML. I want to be able to capture everything between the '/par' tag in the RTF but not include the tag itself. So far all I have is this, '.*?\\par' but it leaves '\par' at the end of it. Any suggestions? (1 Reply)
Discussion started by: AresMedia
1 Replies

3. Shell Programming and Scripting

using regular expressions in c shell control structure

i cant get around using regular expressions in if/else statements. it simply doesnt give me the right results. i've tried using switch/case but that is just as sh!tty as well. (pardon my french but im getting frustrated with c shell..only reason why im writing in it is because it's a hwk... (3 Replies)
Discussion started by: ballazrus
3 Replies

4. UNIX for Advanced & Expert Users

Regular Expressions

Hi, below is a piece of code written by my predecessor at work. I'm kind of a newbie and am trying to figure out all the regular expressions in this piece of code. It is really a tough time for me to figure out all the regular expressions. Please shed some light on the regular expressions... (3 Replies)
Discussion started by: ramky79
3 Replies

5. Shell Programming and Scripting

regular expressions using perl script

i have a set of regular expressions. The words in the regular expression should be used to replace the i/p with hyphens '---'. i need perl script to evaluate these regular expression. the words in the regexes when found in the i/p file should be replaced with hyphens '---'. the set of regular... (3 Replies)
Discussion started by: Sgiri1
3 Replies

6. Shell Programming and Scripting

Regular Expressions in K Shell Script

I need to write a K shell script to find full file names , line numbers and lines which have words meeting either of following 2 criterias - 1)words which are 6 to 8 character long and alphanumeric. 2)Minimum 8 characters, one upper case, one lower case letter, one of the special characters... (1 Reply)
Discussion started by: Rajpreet1985
1 Replies

7. Shell Programming and Scripting

Help with regular expressions

I have a file that I'm trying to find all the cases of phone number extensions and deleting them. So input file looks like: abc x93825 def 13234 x52673 hello output looks like: abc def 13234 hello Basically delete lines that have 5 numbers following "x". I tried: x\(4) but it... (7 Replies)
Discussion started by: pxalpine
7 Replies

8. Shell Programming and Scripting

Small script for website links and regular expressions

Need a help with a simple(i hope) script that would get a website location from stdin and then check all the links that site contains for some random regular expression ,and then save the links name and the expression found in some random file.Any help would be really helpfull. Considerin i`m... (5 Replies)
Discussion started by: Zbunce
5 Replies

9. Shell Programming and Scripting

Regular expressions in tcsh script

Hi, I have a shell script in tcsh to which I pass an argument, the length of which can vary. The possible values of the argument are the letters -c,s,i,q,a. and also a combination of these letters. (e.g: cs,si,ca,iq,qa,csq,acs,csia ..etc). The order of the letters does not matter. My problem... (2 Replies)
Discussion started by: Vaisakh P
2 Replies

10. Shell Programming and Scripting

Regular expressions

I need to pick a part of string lets stay started with specific character and end with specific character to replace using sed command the line is like this:my audio book 71-skhdfon1dufgjhgf8.wav' I want to move the characters beginning with - end before. I have different files with random... (2 Replies)
Discussion started by: XP_2600
2 Replies
nl(1)								   User Commands							     nl(1)

NAME
nl - line numbering filter SYNOPSIS
/usr/bin/nl [-p] [-b [type]] [-d [delim]] [-f [type]] [-h [type]] [-i [incr]] [-l [num]] [-n [format]] [-s [sep]] [-w [width]] [-v [startnum]] [file] /usr/xpg4/bin/nl [-p] [-b type] [-d delim] [-f type] [-h type] [-i incr] [-l num] [-n format] [-s sep] [-w width] [-v startnum] [file] DESCRIPTION
The nl utility reads lines from the named file, or the standard input if no file is named, and reproduces the lines on the standard output. Lines are numbered on the left in accordance with the command options in effect. nl views the text it reads in terms of logical pages. Line numbering is reset at the start of each logical page. A logical page consists of a header, a body, and a footer section. Empty sections are valid. Different line numbering options are independently available for header, body, and footer. For example, -bt (the default) numbers non-blank lines in the body section and does not number any lines in the header and footer sections. The start of logical page sections are signaled by input lines containing nothing but the following delimiter character(s): +-----------------------------+-----------------------------+ | Line contents | Start Of | +-----------------------------+-----------------------------+ |::: |header | +-----------------------------+-----------------------------+ |:: |body | +-----------------------------+-----------------------------+ |: |footer | +-----------------------------+-----------------------------+ Unless optioned otherwise, nl assumes the text being read is in a single logical page body. OPTIONS
Command options may appear in any order and may be intermingled with an optional file name. Only one file may be named. The specified default is used when the option is not entered on the command line. /usr/xpg4/bin/nl options require option arguments. A SPACE character may separate options from option arguments. /usr/bin/nl options may have option arguments. If option-arguments of /usr/bin/nl options are not specified, these options result in the default. The supported options are: -btype Specifies which logical page body lines are to be numbered. Recognized types and their meanings are: a number all lines t number all non-empty lines. n no line numbering pexp number only lines that contain the regular expression specified in exp. See NOTES below. Default type for logical page body is t (text lines numbered). -ftype Same as -btype except for footer. Default type for logical page footer is n (no lines numbered). -ddelim The two delimiter characters specifying the start of a logical page section may be changed from the default characters (:) to two user-specified characters. If only one character is entered, the second character remains the default character (:). No space should appear between the -d and the delimiter characters. To enter a backslash, use two backslashes. -htype Same as -btype except for header. Default type for logical page header is n (no lines numbered). -iincr incr is the increment value used to number logical page lines. Default incr is 1. -lnum num is the number of blank lines to be considered as one. For example, -l2 results in only the second adjacent blank being numbered (if the appropriate -ha, -ba, and/or -fa option is set). Default num is 1. -nformat format is the line numbering format. Recognized values are: ln left justified, leading zeroes suppressed rn right justified, leading zeroes suppressed rz right justified, leading zeroes kept Default format is rn (right justified). -p Do not restart numbering at logical page delimiters. -ssep sep is the character(s) used in separating the line number and the corresponding text line. Default sep is a TAB. -vstartnum startnum is the initial value used to number logical page lines. Default startnum is 1. -wwidth width is the number of characters to be used for the line number. Default width is 6. OPERANDS
The following operand is supported: file A path name of a text file to be line-numbered. EXAMPLES
Example 1 An example of the nl command The command: example% nl -v10 -i10 -d!+ filename1 will cause the first line of the page body to be numbered 10, the second line of the page body to be numbered 20, the third 30, and so forth. The logical page delimiters are !+. ENVIRONMENT VARIABLES
See environ(5) for descriptions of the following environment variables that affect the execution of nl: LANG, LC_ALL, LC_COLLATE, LC_CTYPE, LC_MESSAGES, and NLSPATH. EXIT STATUS
The following exit values are returned: 0 Successful completion. >0 An error occurred. FILES
/usr/lib/locale/locale/LC_COLLATE/CollTable Collation table generated by localedef /usr/lib/locale/locale/LC_COLLATE/coll.so Shared object containing string transformation library routines ATTRIBUTES
See attributes(5) for descriptions of the following attributes: /usr/bin/nl +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWesu | +-----------------------------+-----------------------------+ /usr/xpg4/bin/nl +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWxcu4 | +-----------------------------+-----------------------------+ |Interface Stability |Standard | +-----------------------------+-----------------------------+ SEE ALSO
pr(1), attributes(5), environ(5), regex(5), regexp(5), standards(5) NOTES
Internationalized Regular Expressions are used in the POSIX and "C" locales. In other locales, Internationalized Regular Expressions are used if the following two conditions are met: o /usr/lib/locale/locale/LC_COLLATE/CollTable is present. o /usr/lib/locale/locale/LC_COLLATE/coll.so is not present. Otherwise, Simple Regular Expressions are used. Internationalized Regular Expressions are explained on regex(5). Simple Regular Expressions are explained on regexp(5). SunOS 5.11 28 Mar 1995 nl(1)
All times are GMT -4. The time now is 12:48 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy