Sponsored Content
Top Forums Shell Programming and Scripting Reading a string and passing passing arguments to a while loop Post 302590176 by goddevil on Saturday 14th of January 2012 01:48:00 PM
Old 01-14-2012
Quote:
Originally Posted by agama
Code:
awk -F : -v last=${STOP:-0} -v first=${START:-0} '
    /^#/ { next; }
    NR >= first && (last == 0  || NR <= last) {
        print $1, $2, $3, $0
    }
 
' input-file | while read f1 f2 f3 i
do
        echo "first field: $f1"
        echo "second field $f2"
        echo "third field $f3"
        echo "whole record (i) $i"
done

Thanks Agama. Having tried the code above, i am getting an EOF error. Can you please explain what the awk is doing and if the format of the code is correct? I am getting the following error
Quote:
unexpected EOF while looking for matching `"'
---------- Post updated at 06:48 PM ---------- Previous update was at 05:36 PM ----------

Hi Agama,

I am unfamiliar with the syntax of the belwo code that you provided. I am getting an error from the code. Can you please let me know if the format of the code is correct? Thanks in advance.

Code:
awk -F : -v last=${STOP:-0} -v first=${START:-0} '
    /^#/ { next; }
    NR >= first && (last == 0  || NR <= last) {
        print $1, $2, $3, $0
    }
 
' input-file | while read f1 f2 f3 i
do

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

passing arguments

I'm trying to pass a filename, or all the files in the current directory to the ls command with a script. Unsuccessful so far, here are a few of my attempts: #!/bin/ksh read fname #if (( $# > 0 )); then $fname | ls -l #fi this produces a long listing of all the files in my current... (4 Replies)
Discussion started by: jpprial
4 Replies

2. Shell Programming and Scripting

passing in arguments into a file using a loop

Hi, so Im a bit new to shell scripting and want to do the following but not sure how. Basically I have a file named "output" which contains misc text but inside the file I want to set up variables like $1 or some symbol. Anyways, in another file called "list" I have a list of items that I want to... (11 Replies)
Discussion started by: eltinator
11 Replies

3. Shell Programming and Scripting

Passing Arguments-Help

Hi, I have a script which adds the user credentials to an ldap server. Im passing the variables as below.. /path/my_script $uname $pwd $environ ${deposit} If i enter some special characters like ';' in $pwd, script returns an error which is set to display if the user enters... (5 Replies)
Discussion started by: Tuxidow
5 Replies

4. Shell Programming and Scripting

passing arguments

Hi I have a script to which I pass multiple arguments, for example lets say the script name is "abc". I run the script like ./abc def /file <directory location> In the above "def" is the first argument and "/file" is the second argument. I expect <directory location> that is passed after... (4 Replies)
Discussion started by: zmfcat1
4 Replies

5. Shell Programming and Scripting

Passing arguments to the subshell

I have a shell script which is invoked by passing an argument. The outer shell script calls another subshell and I want the argument passed down to flow down to the subshell. E.g Invoking a shell ======>> abc_refresh.ksh NM Below is the content of abc_refresh.ksh Value1=$1... (7 Replies)
Discussion started by: Mihirjani
7 Replies

6. UNIX for Dummies Questions & Answers

Passing arguments

I need to pass arguments to a shell script.My batch is calling some java program. ################# x=$1 y=$2 java -classpath program ################### if first parameter and second parameter is null then java -classpath program if first parameter is not null and second parameter is... (3 Replies)
Discussion started by: mnjx
3 Replies

7. Shell Programming and Scripting

Passing arguments to csh

I have noticed this thing using csh when passing arguments Suppose I call a csh script using ../Scripts/plot-model.csh -vmod="npt02-z30.vmod" -R="0/80/0/30" -c="0/4.5" -aspr="1:10" Somehow the " get removed when doing $argv ending up with -vmod=npt02-z30.vmod... (0 Replies)
Discussion started by: kristinu
0 Replies

8. Shell Programming and Scripting

Passing arguments that contain space

hi All, i am trying to pass arguments that contain space , value will be stored in variables to be used further in script , i went thru previous posting , still its not clear to how to implement for my case. passing 3 args test.sh it is 'fun to work in unix' inside shell ... (3 Replies)
Discussion started by: gvkk
3 Replies

9. Shell Programming and Scripting

Using here document when passing arguments

I have a script test.sh which reads various inputs from a user. #!/bin/ksh read x read y read z echo x: $x y: $y z: $z # read few more things again read a read b echo a: $a b: $b When i run this script as test.sh << EOF 1 2 EOF (3 Replies)
Discussion started by: ariesb2b
3 Replies

10. Shell Programming and Scripting

How to avoid "Too many arguments" error, when passing a long String literal as input to a command?

Hi, I am using awk here. Inside an awk script, I have a variable which contains a very long XML data in string format (500kb). I want to pass this data (as argument) to curl command using system function. But getting Too many arguments error due to length of string data(payloadBlock). I... (4 Replies)
Discussion started by: cool.aquarian
4 Replies
SCHEME(1)						      General Commands Manual							 SCHEME(1)

NAME
scheme - UMB Scheme ($Revision: 3.2 $) ORIGIN
University of Massachusetts at Boston SYNOPSIS
scheme [file ...] DESCRIPTION
UMB Scheme is an implementation of the language described in the IEEE Standard for the Scheme Programming Language (December, 1990). It also supports R4RS, relying on Aubrey Jaffer's Scheme Portable Library (SLIB) for R4RS macro support. All syntax, variables and procedures are implemented. Integers are implemented as fixnums and bignums, rationals as pairs of integers, (inexact) reals as double-precision floats, and (inexact) complex numbers as pairs of double-precision floats. The following files are loaded in order at startup: If the variable SCHEME_INIT is set in the user's environment by executing setenv SCHEME_INIT file then file is loaded. If SCHEME_INIT is not set and if a file .scheme exists in the user's home directory then it is loaded. The files named as optional arguments are loaded from left to right. The primitive procedure edit may be used for editing files during a scheme session. (edit filename) (edit) Filename is a string object specifying the file to be edited. If no filename is given then that file that was most recently edited is assumed. The editor used is taken from the shell variable, EDITOR, in the user's environment; if this variable is not set then vi(1) is used by default. The user can make sure EDITOR is always set by putting a setenv in his .login file; e.g. setenv EDITOR /usr/ucb/emacs Upon leaving the editor, that file specified by filename is automatically loaded using the primitive procedure loadv, which causes the interpreter output to be sent to the current output port, normally the user's terminal. If verbose loading is not desired use the commands (edits filename) (edits) causing filename to be loaded silently by the primitive procedure load. Load and loadv can be used to load any file in silent or verbose mode respectively: (load filename) (loadv filename). UMB Scheme has property lists: (put symbol property-name object) (get symbol property-name) where property-names are symbols. SCHEME PORTABLE LIBRARY
UMB Scheme can access Aubrey Jaffer's Scheme Portable Library (SLIB). For documentation on SLIB see either http://www.cs.indiana.edu/scheme-repository/SCM/slib_toc.html or /usr/local/lib/slib/slib.texinfo. SYSTEM INTERFACE
UMB Scheme supports calls to the underlying system. The call, (system cmd-string) where cmd-string is a string representing a system command, causes that command to be passed to the underlying operating system. And, (time) returns the number of seconds since 00:00:00 GMT, Jan. 1, 1970. DEFMACRO
UMB Scheme supports the standard defmacro facility. For example, assuming quasi-quote notation, the definition (defmacro := (lhs rhs) `(set! ,lhs ,rhs)) defines a macro := that translates forms like (:= a b) to (set! a b) We rely on the Scheme Portable Library (SLIB) to provide R4RS macros; to load this, type, (require 'macro) EVAL and ENVIRONMENTS We implement environments as first-class Scheme objects and introduce an explicit eval procedure. So, (current-environment) produces the environment in which the call was made. and, (environment? obj) produces #t iff obj is an environment object and #f otherwise. The call, (global-environment obj) produces #t iff obj is the environment object representing the top-level global environment and #f otherwise. Environment objects are used by eval. The call, (eval obj environment) explicitly evaluates the given object in the given environment. For example, (define env1 (current-environment)) ; => env1 (define env2 nil) ; => env2 (define x 0) ; => x (define form '(+ x 1)) ; => form (let ((x 10)) (set! env2 (current-environment)) nil) ; => nil (define env3 (let ((x 15)) (current-environment))) ; => env3 ; Now, here's the rub (eval form env1) ; => 1 (eval form env2) ; => 11 (eval form env3) ; => 16 The second argument to eval is optional, in which case it defaults to the current environment. For example, (define x 0) ; => x (define form '(+ x 1)) ; => form (eval form) ; => 1 (let ((x 10)) (eval form)) ; => 11 UMB Scheme implements a macro definition defining the macro form make-environment, such that (make-environment (define <name1> <expr1>) ... (define <namen> <exprn>)) defines a new environment, composed of the current environment augmented by a new nested frame comprised of the given definitions. Of course, (make-environment) without any definitions has the same effect as (current-environment) DEBUGGING
UMB Scheme has a simple debugger. Throughout a session one is in one of two modes: top-level mode or debugging mode. In general, one works in top-level mode. If the debugger has been turned on, an error raised during an evaluation (or an explicit call to break) causes a break which puts the user into debugging mode. The user can place explicit calls to break or error in his code: (break obj ...); Print the objects and break the evaluation. (error obj ...); Print the objects and raise an error. In debugging mode, certain primitives apply for finding the cause of the offense. Notice that syntax errors cause a reset , returning the user to top-level mode. When the debugger is turned off, all errors simply cause a reset to top-level mode. (debug) ; turn on the debugger (debug-off) ; turn off the debugger. NB: When the debugger is turned on, UMB Scheme is no longer properly tail-recursive as required by the language definition. For this rea- son, the debugger is turned off by default. One can insure the debugger is always turned on by putting a call to debug in the Scheme Init file (e.g. .scheme). Any scheme expression may be evaluated in debugging mode. It is evaluated in the environment that existed when the break occurred in the top level computation; this makes it easy to find the bindings for local variables. In addition, the following primitives apply. (reset) ; Return to the top-level read-eval-print loop. Control-D ; Typing Control-D causes a (reset). (show-env) ; Show the bindings of all local environments. (show-env k) ; Show-env for only the k most recent frames. (show-globals) ; Show bindings for all user-defined globals. (show-proc-env proc); Show a procedure's environment. (how symbol) ; Show the expression causing symbol's binding. (where) ; Show an enumerated backtrace of the ; computation being debugged. (where k) ; Show the most recent k steps of the backtrace. (go obj) ; Resume the computation being debugged, ; substituting the value of obj for the most recent ; step (as indicated by a call to where). (go k obj) ; Likewise, but obj is substituted for the k-th step ; as enumerated in the backtrace by (where). Tracing a procedure involves interrupting evaluation when either the procedure is about to be applied or the procedure is about to return with a value. Upon such an interruption, the call or the returned value is printed, and the user is put in debugging mode. (trace proc ...); Trace named procedures. (trace) ; Trace all procedures. (untrace proc ...); Cancel tracing for named procedures. (untrace) ; Cancel tracing for all procedures. Control-D ; Resume the computation interrupted in the trace. Stepping through a computation involves interrupting evaluation at every k-th expression, for a given k. The expression in question is printed and the user is put in debugging mode. (step k) ; Interrupt evaluation at every k-th expression. (step 0) ; Inhibit stepping altogether. Control-D ; Resume the evaluation broken in the stepping. Notice that, when stepping or tracing is in effect, any one of a number of events (the application of a procedure or the k-th expression being reached) will interrupt evaluation. Since typing Control-D resumes the interrupted computation, one can step through such a computa- tion by repeatedly typing Control-D. Finally, errors or explicit calls to break arising while in debugging mode simply leave the user in debugging mode. Unlike some other implementations, UMB Scheme does not support nested debugging sessions. (Keep it simple.) FILES
/usr/share/ubm-scheme/prelude.scheme /usr/share/umb-scheme/SLIB-for-umb-scheme.init /usr/local/lib/slib/* SEE ALSO
Release Notes COPYING
Copyright (C) 1988, 1990 William R Campbell Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on all copies. Permission is granted to copy and distribute modified versions of this manual under the conditions for verbatim copying, provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one. AUTHOR
William Campbell, University of Massachusetts at Boston, with help from Karl Berry,Barbara Dixey, Ira Gerstein, Mary Glaser, Kathy Harg- reaves, Bill McCabe, Long Nguyen, Susan Quina, Jeyashree Sivasubram, Bela Sohoni and Thang Quoc Tran. BUGS
No doubt, there are bugs. Please report them to bill@cs.umb.edu. local Janaury 22, 1996 SCHEME(1)
All times are GMT -4. The time now is 05:57 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy