That looks like it should work, though like I said, the grep/awk solution would be more efficient. Maybe you should put double-quotes around the $line, as in:
In ksh and bash, you can also parse out the first word from the rest:
I'm trying to parse COBOL code to combine variables into one string. I have two variable names that get literals moved into them and I'd like to use sed, awk, or similar to find these lines and combine the variables into the final component. These variable names are always VAR1 and VAR2. For... (8 Replies)
Hi all
I've been working on a bash script parsing through debug/trace files and extracting all lines that relate to some search string. So far, it works pretty well. However, I am challenged by one requirement that is still open.
What I want to do:
1) parse through a file and identify all... (3 Replies)
I want to search files (basically .cc files) in /xx folder and subfolders.
Those files (*.cc files) must contain #include "header.h" AND x() function.
I am writing it another way to make it clear,
I wanna list of *.cc files that have 'header.h' & 'x()'. They must have two strings, header.h... (2 Replies)
Hey guys. I know pratically 0 about Linux, so could anyone please give me instructions on how to accomplish this ?
The distro is RedHat 4.1.2 and i need to find and replace a multiple lines string in several php files across subdirectories.
So lets say im at root/dir1/dir2/ , when i execute... (12 Replies)
Hi,
I want to grep multiple patterns from multiple files and save to multiple outputs. As of now its outputting all to the same file when I use this command.
Input : 108 files to check for 390 patterns to check for. output I need to 108 files with the searched patterns.
Xargs -I {} grep... (3 Replies)
Hello,
I would like to ask for help with csh script.
An example of an input in .txt file is below, the number of lines varies from file to file and I have 2 or 3 columns with values. I would like to read all the values (probably one by one) and set them to independent unique variables that... (7 Replies)
GM,
I have an issue at work, which requires a simple solution. But, after multiple attempts, I have not been able to hit on the code needed.
I am assuming that sed, awk or even perl could do what I need.
I have an application that adds extra blank page feeds, for multiple reports, when... (7 Replies)
Hello Gurus,
I have a multiple pipe separated files which have records going over multiple Lines. End of line separator is \n and records going over multiple lines have <CR> as separator. below is example from one file.
1|ABC DEF|100|10
2|PQ
RS
T|200|20
3| UVWXYZ|300|30
4| GHIJKL|400|40... (7 Replies)
Hi All,
I have below text, i want to add " in it, please advise.
FORD MOTOR COMPANY FORD COMPONENT SALES, LLC Mazda Motor Manufacturing de Mexico, S.A. de C.V.
Desired:
"FORD MOTOR COMPANY" "FORD COMPONENT SALES, LLC"" Mazda Motor Manufacturing de Mexico, S.A. de C.V."
edit by bakunin:... (2 Replies)
Discussion started by: Amit Saroha
2 Replies
LEARN ABOUT OSF1
getopt
getopt(1) General Commands Manual getopt(1)NAME
getopt - Parses command line flags and arguments
SYNOPSIS
getopt format tokens
DESCRIPTION
The getopt command is used to parse a list of tokens using a format that specifies expected flags and arguments. A flag is a single ASCII
letter and, when followed by a : (colon), is expected to take a modifying argument that may or may not be separated from it by one or more
tabs or spaces. (You can include multi-byte characters in arguments, but not as flag letters.)
The getopt command completes processing when it has read all tokens or when it encounters the special token -- (double dash). It then out-
puts the processed flags, a --, and any remaining tokens.
If a token fails to match a flag, getopt writes a message to standard error.
NOTES
In the csh, use the following command to run getopt:
set argv=`getopt flag_string $*`
EXAMPLES
The following is an example of the use of getopt in a skeleton shell script to parse options:
#!/bin/sh # parse command line into arguments set -- `getopt a:bc $*` # check result of parsing if [ $? != 0 ] then
exit 1 fi while [ $1 != -- ] do
case $1 in
-a) # set up the -a flag
AFLG=1
AARG=$2
shift;;
-b) # set up the -b flag
BFLG=1;;
-c) # set up the -c flag
CFLG=1;;
esac
shift # next flag done shift # skip double dash # now do the work . . .
The following are all equivalent arguments to the script:
-a ARG -b -c -- A B C -a ARG -bc -- A B C -aARG -b -c -- A B C -b -c -a ARG -- A B C
SEE ALSO
Commands: sh(1)
Functions: getopt(3)getopt(1)