Sponsored Content
Full Discussion: Parse Line Using Sed
Top Forums Shell Programming and Scripting Parse Line Using Sed Post 302152479 by fpmurphy on Thursday 20th of December 2007 12:57:52 AM
Old 12-20-2007
Actually no. The -F: option is not required because of the space after the colon on each line.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to parse a line?

I'm currenting trying to parse the out put of the following command. iostat -xtc -r |grep cmdk0 which produces the output cmdk0,0.2,0.0,1.2,0.0,0.0,0.0,39.7,0,0,0,0,0,0,0,99 I'm then trying to get the data to look like this: rw=0.2 ws=0.0 krs=1.2 kws=0.0 wait=0.0 actv=0.0... (2 Replies)
Discussion started by: edefoe
2 Replies

2. Shell Programming and Scripting

please help to parse the line

cp4 0 0 170.217.86.10.1421 170.217.86.8.53308 ESTABLISHED tcp4 0 0 170.217.86.10.1421 170.217.86.8.62948 ESTABLISHED tcp4 0 0 170.217.86.10.1421 170.217.86.8.62949 ESTABLISHED tcp4 0 0 170.217.86.10.1421 ... (1 Reply)
Discussion started by: ajaya
1 Replies

3. Shell Programming and Scripting

please help to parse the line

cp4 0 0 170.217.86.10.1421 170.217.86.8.53308 ESTABLISHED tcp4 0 0 170.217.86.10.1421 170.217.86.8.62948 ESTABLISHED tcp4 0 0 170.217.86.10.1421 170.217.86.8.62949 ESTABLISHED tcp4 0 0 170.217.86.10.1421 ... (1 Reply)
Discussion started by: ajaya
1 Replies

4. Shell Programming and Scripting

SED help (remove line::parse again::add line)

Aloha! I have just over 1k of users that have permissions that they shouldn't under our system. I need to parse a provided list of usernames, check their permissions file, and strip the permissions that they are not allowed to have. If upon the permissions strip they are left with no permissions,... (6 Replies)
Discussion started by: Malumake
6 Replies

5. Shell Programming and Scripting

Parse String Using Sed

Hi, I am wondering if there's a simpler way to extract the second occurrence of a word enclosed in that matches my search criteria. Sample Input is as follows: Error installing feature - com.er.nms.cif.ist.NoMatchingUpgra Error installing feature -... (4 Replies)
Discussion started by: racbern
4 Replies

6. UNIX for Advanced & Expert Users

how do you parse 1 line at a time of file1 ie. line(n) each line into new file

File 1 <html>ta da....unique file name I want to give file=>343...</html> <html>da ta 234 </html> <html>pa da 542 </html> and so on... File 2 343 234 542 and so on, each line in File 1 one also corresponds with each line in File 2 I have tried several grep, sed, while .. read, do,... (4 Replies)
Discussion started by: web_developer
4 Replies

7. Shell Programming and Scripting

To parse the line

Hi, I have a line QMNAME(qmgrname) STATUS(RUNNING) Can u jus tell me how to only get the status field ? And also the value of the status whether it is running or not running. -- Thanks (2 Replies)
Discussion started by: julie_s
2 Replies

8. Shell Programming and Scripting

sed to parse html

Hello, I have a html file like this : <html> ... ... ... <table> ....... ...... </table> <table name = "hi"> ...... ..... ... </table> <h1> Welcome </h1> ....... ...... </html> (11 Replies)
Discussion started by: prasanna1157
11 Replies

9. Shell Programming and Scripting

parse log with sed

I've been searching for an hour on how to parse a file like this: 10.200.5.83 - - "GET /portal/edits.js HTTP/1.1" 200 24324 10.200.5.83 - - "GET /portal/objects/PortalConfig.js HTTP/1.1" 200 12187 10.200.5.84 - - "GET /portal/objects/CommonDialog.js HTTP/1.1" 200 8283 10.200.5.84 - - "GET... (4 Replies)
Discussion started by: dba_frog
4 Replies

10. Shell Programming and Scripting

Ksh: Read line parse characters into variable and remove the line if the date is older than 50 days

I have a test file with the following format, It contains the username_date when the user was locked from the database. $ cat lockedusers.txt TEST1_21062016 TEST2_02122015 TEST3_01032016 TEST4_01042016 I'm writing a ksh script and faced with this difficult scenario for my... (11 Replies)
Discussion started by: humble_learner
11 Replies
getopt(3C)																getopt(3C)

NAME
getopt(), optarg, opterr, optind, optopt - get option letter from argument vector SYNOPSIS
DESCRIPTION
returns the next option letter in argv (starting from that matches a letter in optstring. argc and argv are the argument count and argu- ment array as passed to optstring is a string of recognized option characters; if a character is followed by a colon, the option takes an argument which may or may not be separated from it by whitespace. is the index of the next element of the vector to be processed. It is initialized to 1 by the system, and updates it when it finishes with each element of returns the next option character from argv that matches a character in optstring, if there is one that matches. If the option takes an argument, sets the variable to point to the option argument as follows: o If the option was the last character in the string pointed to by an element of argv, then contains the next element of argv, and is incremented by 2. If the resulting value of is greater than or equal to argc, this indicates a missing option argument, and returns an error indication. o Otherwise, points to the string following the option character in that element of argv, and is incremented by 1. If, when is called, is NULL, or the string pointed to by either does not begin with the character or consists only of the character returns -1 without changing If points to the string returns -1 after incrementing If encounters an option character that is not contained in optstring, it returns the question-mark character. If it detects a missing option argument, it returns the colon character if the first character of optstring was a colon, or a question-mark character otherwise. In either case, sets the variable to the option character that caused the error. If the application has not set the variable to zero and the first character of optstring is not a colon, also prints a diagnostic message to standard error. The special option can be used to delimit the end of the options; -1 is returned, and is skipped. RETURN VALUE
returns the next option character specified on the command line. A colon is returned if detects a missing argument and the first character of optstring was a colon A question-mark is returned if encounters an option character not in optstring or detects a missing argument and the first character of optstring was not a colon Otherwise, returns -1 when all command line options have been parsed. EXTERNAL INFLUENCES
Locale The category determines the interpretation of option letters as single and/or multi-byte characters. International Code Set Support Single- and multibyte character code sets are supported. ERRORS
fails under the following conditions: [EILSEQ] An invalid multibyte character sequence was encountered during option processing. EXAMPLES
The following code fragment shows to process arguments for a command that can take the mutually exclusive options and and the options and both of which require arguments: #include <stdio.h> #include <unistd.h> main (int argc, char *argv[]) { int c; int bflg, aflg, errflg; extern char *optarg; extern int optind, optopt; . . . while ((c = getopt(argc, argv, ":abf:o:")) != -1) switch (c) { case 'a': if (bflg) errflg++; else aflg++; break; case 'b': if (aflg) errflg++; else { bflg++; bproc( ); } break; case 'f': ifile = optarg; break; case 'o': ofile = optarg; break; case ':': /* -f or -o without arguments */ fprintf(stderr, "Option -%c requires an argument ", optopt); errflg++; break; case '?': fprintf(stderr, "Unrecognized option: - %c ", optopt); errflg++; } if (errflg) { fprintf(stderr, "usage: . . . "); exit(2); } for ( ; optind < argc; optind++) { if (access(argv[optind], 4)) { . . . } WARNINGS
Options can be any ASCII characters except colon question mark or null SEE ALSO
getopt(1), thread_safety(5). STANDARDS CONFORMANCE
getopt(3C)
All times are GMT -4. The time now is 08:43 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy