Sponsored Content
Full Discussion: Shell: Parsing Input
Homework and Emergencies Homework & Coursework Questions Shell: Parsing Input Post 302499599 by someoney3000 on Thursday 24th of February 2011 08:50:29 PM
Old 02-24-2011
Quote:
Originally Posted by frank_rizzo
strtok can do the job fairly easily and does support mutiple tokens. check out flex. it's built for tasks like this if your allowed to use it. what is your desired output?
I don't think I'm actually allowed to use it~

Right now, I'm attempting to build an AST tree, starting simple.

First I parse ';'. Easy enough.

I'm stuck on '&' with the tokenizer though. I can't tokenize using '&' because something like 'blah blah &' won't work. I can't depend on the first occurrence because something like 'blah & blah&' won't work. So, I'm thinking of parsing it manually.

>.>

Personally, I'm going to avoid regexps since I'm not too good with them.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Parsing input paramter in a script

Hi folks I am having a little trouble in parsing a variable read into a ksh script I have a bunch of variables passed into script test.ksh HOST SERVER JOB1 JOB2 JOB3 JOB4 JOB5 What I want to do is read all the $JOB variables ($JOB1, $JOB2, $JOB3) into a variable and then read that variable... (2 Replies)
Discussion started by: Anubhav
2 Replies

2. Shell Programming and Scripting

parsing file2 with input from file1

Sorry dublication with previous thread... please delete it Hi all i need and appreciate your help creating a script in ksh for the following case Two files exists with questionmark delemeter: File1.txt: A;B;C;F;D;K; File2.txt A,name,address1; K,name,surname,phone; C,name,phone;... (1 Reply)
Discussion started by: forumsgr
1 Replies

3. Shell Programming and Scripting

Parsing in korn shell

Hi Everyone, how do i parse following string from a file xyz.log in korn shell ? aa/bb{ CT{ GG{jjj/test} Thanks in advance, sweta (1 Reply)
Discussion started by: swetarati
1 Replies

4. UNIX for Dummies Questions & Answers

Parsing name and phone as input and then print sub and marks out

I have a file like this : name phone id sub marks abc 2345 45 mat 90 bgt 6573 54 eng 89 ... .... .. ... .. ... .... .. ... .. Now i need to take in name and phone as input and then print sub and marks out, can u give me a sample code for this. P.S. If there are two of with same... (2 Replies)
Discussion started by: SasankaBITS
2 Replies

5. Shell Programming and Scripting

Help parsing job script input parameters

I have a job script that runs with input parms from the command line. job.sh -p parm1_parm2_parm3_parm4_file_1.dat The parms are separated by _ The last parm is a file name and can have an _ in the name. I currently use the following commands to extract the parms parm1=`eval echo... (3 Replies)
Discussion started by: jclanc8
3 Replies

6. Shell Programming and Scripting

parsing using shell script

I have a file parameters.txt which contains 151524 151525 I have another file OID.csv which contains NE Version Object Type ID SDK param name Object OID test1 Start: 4.2 End: 4.2 pan 151524 speed ... (5 Replies)
Discussion started by: LavanyaP
5 Replies

7. Homework & Coursework Questions

Problem parsing input with awk

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: I want add a line.For example:- 123456 1 1 0 1 1 0 1 0 0 0 1 5 8 0 12 10 25 its answer... (4 Replies)
Discussion started by: Arsh10
4 Replies

8. Shell Programming and Scripting

Input handling and formatting input to shell

i want to get input and depending on it create new commands for input to expect. But problem is that after giving date or month as 01-09 it is interpretation as 1-9 echo -n "ENTER DATE " read d1 echo -n "ENTER MONTH " read m1 echo -n "ENTER YEAR" read y1 o=1 i=1 d2=`expr $d1... (1 Reply)
Discussion started by: sagar_1986
1 Replies

9. Shell Programming and Scripting

Parsing C Data Tipes from Input File

Im really beginner in this case, maybe someone can help me find the answer: if my input file like this: void main(int a, int b){ int x; double y; printf("file"); } and i want output like this: int a int b int x double y A awk script that can parse only data tipe, im confused. what... (2 Replies)
Discussion started by: radynaraya
2 Replies

10. Shell Programming and Scripting

Need help in parsing an input in perl

I am executing a command it is returning me something like this name ip port ------------------------------------ http-listener-1 * 6712 http-listener-2 * 8709 I have a subroutine getListenerName($porttobeChecked) This subroutine returns me the name of the listener if i pass a... (4 Replies)
Discussion started by: javaholics
4 Replies
bc(1)							      General Commands Manual							     bc(1)

NAME
bc - arbitrary-precision arithmetic language SYNOPSIS
[file...] DESCRIPTION
is an interactive processor for a language that resembles C but provides unlimited-precision arithmetic. It takes input from any files given, then reads the standard input. Options recognizes the following command-line options: Compile only. is actually a preprocessor for which invokes automatically (see dc(1)). Specifying prevents invoking dc, and sends the dc input to standard output. causes an arbitrary-precision math library to be predefined. As a side effect, the scale factor is set. Program Syntax L a single letter in the range through E expression; S statement; R relational expression. Comments Comments are enclosed in and Names Names include: simple variables: L array elements: L [ E ] stacks: L Other Operands Other operands include: Arbitrarily long numbers with optional sign and decimal point. ( E ) sqrt ( E ) length ( E ) number of significant decimal digits scale ( E ) number of digits right of decimal point L ( E , ... , E ) Strings of ASCII characters enclosed in quotes (""). Arithmetic Operators: Arithmetic operators yield an E as a result and include: is remainder (not mod, see below); is power). (prefix and append; apply to names) Relational Operators Relational operators yield an R when used as op Statements E { S ; ... ; S } if ( R ) S while ( R ) S for ( E ; R ; E ) S null statement break quit Function Definitions define L ( L ,..., L ) { auto L, ... , L S; ... S return ( E ) } Functions in -l Math Library Functions in the math library include: s(x) sine c(x) cosine e(x) exponential l(x) log a(x) arctangent j(n,x) Bessel function All function arguments are passed by value. Trigonometric angles are in radians where 2 pi radians = 360 degrees. The value of a statement that is an expression is printed unless the main operator is an assignment. No operators are defined for strings, but the string is printed if it appears in a context where an expression result would be printed. Either semicolons or new-lines can sepa- rate statements. Assignment to scale influences the number of digits to be retained on arithmetic operations in the manner of dc(1). Assignments to or set the input and output number radix respectively, again as defined by dc(1). The same letter can be used simultaneously as an array, a function, and a simple variable. All variables are global to the program. "Auto" variables are pushed down during function calls. When using arrays as function arguments or defining them as automatic variables, empty square brackets must follow the array name. The operator yields the remainder at the current scale, not the integer modulus. Thus, at scale 1, is .1 (one tenth), not 1. This is because (at scale 1) is 2.3 with .1 as the remainder. EXAMPLES
Define a function to compute an approximate value of the exponential function: Print approximate values of the exponential function of the first ten integers. WARNINGS
There are currently no (AND) or (OR) comparisons. The statement must have all three expressions. is interpreted when read, not when executed. parser is not robust in the face of input errors. Some simple expression such as 2+2 helps get it back into phase. The assignment operators: and are obsolete. Any occurences of these operators cause a syntax error with the exception of which is inter- preted as followed by a unary minus. Neither entire arrays nor functions can be passed as function parameters. FILES
desk calculator executable program mathematical library SEE ALSO
bs(1), dc(1). tutorial in STANDARDS CONFORMANCE
bc(1)
All times are GMT -4. The time now is 06:55 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy