Sponsored Content
Full Discussion: Beginning learner
Top Forums Shell Programming and Scripting Beginning learner Post 303000316 by shiver on Monday 10th of July 2017 01:48:50 AM
Old 07-10-2017
Beginning learner

Hi guys,

New member here, also new student!

I'm just starting the Shell Programming, currently in chapter four in the Book in Unix, Linux, and OS X by Stephen G. Kochan & Patrick Wood (4th edition).

I'm needing a little help with other possible ways to shorten this shell command:
Code:
/[0-9][0-9][0-9][0-9][ \][0-9][0-9][0-9][0-9][0-9][0-9][ \][0-9][0-9][0-9][0-9][0-9]/

It's purpose is to bed used in ed with a file open with possible matches.

This question was presented as follows:

Using the Regular Expression techniques that we have discussed in class develop, test, and submit a regular expression that will identify each of the following patterns.

An American Express credit card number that fits the following format: 4 digits followed by a space followed by 6 digits followed by a space followed by 5 digits.

Any input or help would be greatly appreciated!

If not, I'm happy to be a member here! Smilie

Thanks

Moderator's Comments:
Mod Comment Please use code tags for you code and data, as requested by our forum rules, thanks

Last edited by vbe; 07-10-2017 at 03:19 AM.. Reason: code tags please even for so lttle...
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

I am a fresh learner of unix,and hope for some help here.

Who could tell me how to learn unix fastly? (4 Replies)
Discussion started by: dsun5
4 Replies

2. IP Networking

Apache: In the beginning...

:D Hello Everyone, This is my first post on this forum, and I a already like it :-) As you can tell I am a complete newbie to Apache. My mission is to setup a web server on my Suse Linux 8.1 box, initially for test purposes, and then if my ISP provider permits, then to allow other poeple... (10 Replies)
Discussion started by: bionicfysh
10 Replies

3. UNIX for Dummies Questions & Answers

beginning unix

i am fairly new to unix, and i would want a very simple, small command-line operating system to learn as much as possible. are there any good ones? i have a fairly old laptop w/ about 700 MB, running windows 95. i would like to partition it, anyone know how to do that? any help is very much... (1 Reply)
Discussion started by: henroid815
1 Replies

4. UNIX for Dummies Questions & Answers

the very beginning

Actually, I had my first problem before even BEGINNING using my FreeBSD. The installation guide said I should run the rawrite tool and should do something like A> rawrite if i put the the file I want to image-copy and the rawrite.exe in the same directory somewhere. OK done that. Next it asks... (6 Replies)
Discussion started by: Mudrack
6 Replies

5. Post Here to Contact Site Administrators and Moderators

Thread closed when learner has tried

I'm not so sure that this thread should have been closed. Though it was clearly homework the student was asking a specific question related to the assignment, but not the answer to the whole assignment. /www.unix.com/unix-dummies-questions-answers/107494-how-get-rid.html . IMHO The solution is... (1 Reply)
Discussion started by: methyl
1 Replies

6. Shell Programming and Scripting

i am new learner from shell scripting.. any one help me.

hi every body, i am ramesh. i want write about this shell program (" i have 94 server's like aix, solaris, linux, hp-ux, and sco unix-") how to get mail's from these server's? (i have personal linux system)- i want to run this program in my personal linux system continuously. i want to... (4 Replies)
Discussion started by: rameshreddy.ema
4 Replies

7. Programming

Beginning C++

I want to learn C++ ! :) I have basic programming knowledge with python and perl. Does anyone know of any great beginner tutorials for C++? (1 Reply)
Discussion started by: cbreiny
1 Replies

8. Red Hat

learner Shell

a task given to me is to make a shell which will have the following qualities.... "The most rudimentary shell is structured as the following loop: 1. Print out a prompt (e.g., "OS_Spring2011_Shell$ "); 2. Read a line from the user; 3. Parse the line into the program name and an array of... (2 Replies)
Discussion started by: hamidnasir
2 Replies

9. AIX

Learner FTP help

Hello All, Real Newbie to AIX I need to automate an FTP server to Server. Want to push the files from an AIX server to an OSX server. What would be the best command in AIX to do this? Need help copying contents of \UVdata to 172.16.12.2\ERAbackup\1 Or Alternatively would it be better... (1 Reply)
Discussion started by: Joelly
1 Replies

10. Shell Programming and Scripting

beginning less from line #

Hi from a script i want to to read a file beginning at line e.g. number 21 to the EOF. less +n21 temp.txt Bevor the result, it brings an empty page, so that i cant use for scripting. Any idea how the problem can be solved? Thanks in advance! IMPe (2 Replies)
Discussion started by: IMPe
2 Replies
grep(1) 						      General Commands Manual							   grep(1)

NAME
grep, egrep, fgrep - search a file for a pattern SYNOPSIS
Plain call with pattern pattern [file ...] Call with (multiple) -e pattern pattern] ... [file ...] Call with -f file pattern_file] [file ...] Obsolescent: [expression] [file ...] [strings] [file ...] DESCRIPTION
The command searches the input text files (standard input default) for lines matching a pattern. Normally, each line found is copied to the standard output. supports the Basic Regular Expression syntax (see regexp(5)). The option supports Extended Regular Expression (ERE) syntax (see regexp(5)). The option searches for fixed strings using the fast Boyer-Moore string searching algorithm. The and options treat newlines embedded in the pattern as alternation characters. A null expression or string matches every line. The forms and are maintained for backward compatibility. The use of the and options is recommended for portability. Options Extended regular expressions. Each pattern specified is a sequence of one or more EREs. The EREs can be separated by newline characters or given in separate expression options. A pattern matches an input line if any ERE in the sequence matches the contents of the input line without its trailing newline character. The same functionality is obtained by using Fixed strings. Each pattern specified is a sequence of one or more strings. Strings can be separated by newline characters or given in separate expression options. A pattern matches an input line if the line contains any of the strings in the sequence. The same functionality is obtained by using Each line is preceded by the block number on which it was found. This is useful in locating disk block numbers by context. Block numbers are calculated by dividing by 512 the number of bytes that have been read from the file and rounding down the result. Only a count of matching lines is printed. Same as a simple expression argument, but useful when the expression begins with a hyphen Multiple options can be used to specify multiple patterns; an input line is selected if it matches any of the specified patterns. The regular expression and or strings list is taken from the pattern_file. Suppress printing of filenames when searching multiple files. Ignore uppercase/lowercase distinctions during comparisons. Only the names of files with matching lines are listed (once), separated by newlines. If standard input is searched, a path name of will be written, in the POSIX locale. In other locales, may be replaced by something more appropriate in those locales. Each line is preceded by its relative line number in the file starting at 1. The line number is reset for each file searched. This option is ignored if or is specified. (Quiet) Do not write anything to the standard output, regardless of matching lines. Exit with zero status upon finding the first matching line. Overrides any options that would produce output. Error messages produced for nonexistent or unreadable files are suppressed. All lines but those matching are printed. 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 pre- ceded by a non-word constituent character. Similarly, it must be either at the end of the line or followed by a non-word constituent character. Word-constituent characters are letters, digits, and the underscore. (eXact) Matches are recognized only when the entire input line matches the fixed string or regular expression. The file name is output in all the cases in which output is generated if there are more than one input file, unless the -h option is speci- fied. Care should be taken when using the characters and in expression, because they are also meaningful to the shell. It is safest to enclose the entire expression argument in single quotes EXTERNAL INFLUENCES
Environment Variables determines the locale to use for the locale categories when both and the corresponding environment variable (beginning with do not specify a locale. If is not specified or is set to the empty string, a default of (see lang(5)) is used. determines the locale to use to override any values for locale categories specified by the settings of or any environment variables begin- ning with determines the collating sequence used in evaluating regular expressions. determines the interpretation of text as single byte and/or multi-byte characters, the classification of characters as letters, the case information for the option, and the characters matched by character class expressions in regular expressions. determines the language in which messages are displayed. If any internationalization variable contains an invalid setting, the commands behave as if all internationalization variables are set to See environ(5). International Code Set Support Single-byte and multi-byte character code sets are supported. RETURN VALUE
Upon completion, returns one of the following values: One or more matches found. No match found. Syntax error or inaccessible file (even if matches were found). EXAMPLES
In the POSIX shell (sh(1)) the following example searches two files, finding all lines containing occurrences of any of four strings: Note that the single quotes are necessary to tell when the strings have ended and the file names have begun. For the C shell (see csh(1)) the following command can be used: To search a file named containing the following entries: the command: prints: To search a file for lines that contain either a or use either of the following commands: Search all files in the current directory for the string Search all files in the current directory subtree for the string and ensure that no error occurs due to file name expansion exceeding sys- tem argument list limits: The previous example does not print the name of files where string appears. To force to print file names, add a second argument to the command portion of the command line: In this form, the first file name is that produced by and the second file name is the null file. WARNINGS
(XPG4 only.) If the option is specified, the exit status will be zero if an input line is selected, even if an error was detected. Other- wise, default actions will be performed. If the option is specified with non-word constituent characters, then the output is unexpected. SEE ALSO
sed(1), sh(1), regcomp(3C), environ(5), lang(5), regexp(5). STANDARDS CONFORMANCE
grep(1)
All times are GMT -4. The time now is 03:55 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy