print user variable input


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers print user variable input
Prev   Next
# 1  
Old 10-04-2012
print user variable input

this may be basic thing for everyone here, but i cant push awk to print the variable user input which is INS, please help.

code:
Code:
INS=$1

printf '\n'
symdg list | grep $INS-clone | awk -v i=$INS '{ID=substr($4,9,4)}{print "Device Group: "$1,"at Array "ID,i}'

output:
Code:
$ ./test.sh patty

awk: syntax error near line 1
awk: bailing out near line 1

 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

User input and run awk using the input

I am trying to allow a user to enter in text and then store that text in a variable $gene to run in an awk command in which those values are used to run some calculations. I am getting syntax errors however, when I try. Thank you :). The awk runs great if it is a pre-defined file that is used,... (7 Replies)
Discussion started by: cmccabe
7 Replies

2. UNIX for Advanced & Expert Users

Passing variable as input & storing output in other variable

I have a below syntax its working fine... var12=$(ps -ef | grep apache | awk '{print $2,$4}') Im getting expected output as below: printf "%b\n" "${VAR12}" dell 123 dell 456 dell 457 Now I wrote a while loop.. the output of VAR12 should be passed as input parameters to while loop and results... (5 Replies)
Discussion started by: sam@sam
5 Replies

3. Shell Programming and Scripting

To print value for a $variable inside a $variable or file

Hi guys, I have a file "abc.dat" in below format: FILE_PATH||||$F_PATH TABLE_LIST||||a|b|c SYST_NM||||${SRC_SYST} Now I am trying to read the above file and want to print the value for above dollar variables F_PATH and SRC_SYST. The problem is it's reading the dollar variables as... (5 Replies)
Discussion started by: abcabc1103
5 Replies

4. Shell Programming and Scripting

XML variable for input in same input file

Dear All , i stuck in one problem executing xml .. i have input xml as <COMMAND name="ARRANGEMENT.WRITE" timestamp="0" so="initial"> <SVLOBJECT> <LONG name="CSP_PMNT_ID" val="-1"/> <MONEY name="CSP_CEILING" amount="0.0" currency="AUD"/> ... (6 Replies)
Discussion started by: arvindng
6 Replies

5. Shell Programming and Scripting

awk print variable then fields in variable

i have this variable: varT="1--2--3--5" i want to use awk to print field 3 from this variable. i dont want to do the "echo $varT". but here's my awk code: awk -v valA="$varT" "BEGIN {print valA}" this prints the entire line. i feel like i'm so close to getting what i want. i... (4 Replies)
Discussion started by: SkySmart
4 Replies

6. Shell Programming and Scripting

How to print column by getting user input.?

Hi.. I have data file.. and I could able to print using cat and awk like this cat filename awk '{print $1 "\t" $2 "\t" $3}' filenamebut I want to receive input from user like this echo -n " how many columns you want to display : " read abcsuppose if I give all, it should display all... (11 Replies)
Discussion started by: Akshay Hegde
11 Replies

7. Shell Programming and Scripting

Script interacts with user , based on user input it operates

i have a script which takes input from user, if user gives either Y/y then it should continue, else it should quit by displaying user cancelled. #!/bin/sh echo " Enter your choice to continue y/Y OR n/N to quit " read A if then echo " user requested to continue " ##some commands... (7 Replies)
Discussion started by: only4satish
7 Replies

8. Shell Programming and Scripting

How to get the user input recursively until the user provides valid input

Hi, echo "Enter file name of input file list along with absolute path : " read inputFileList if then for string in `cat inputFileList` do echo $string done else echo " file does not exist" fi From the above code, if the user enters a invalid file... (1 Reply)
Discussion started by: i.srini89
1 Replies

9. 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

10. Shell Programming and Scripting

Force Input in User Defined Variable

In a line such as: echo -n "How many days back would you like to check? "; read days How can I ensure that the user has a.) entered a number between 1-30 (not 0 or 31+) and b.) has not just hit enter (ie set it to "") and if it's entered wrong, how do I start the if statement over? I... (10 Replies)
Discussion started by: earnstaf
10 Replies
Login or Register to Ask a Question
GROG(1)                                                       General Commands Manual                                                      GROG(1)

NAME
grog -- guess options for a following groff command SYNOPSIS
grog [-C] [--run] [--warnings] [--ligatures] [ groff-option ....] [--] [ filespec ....] grog -h | --help grog -v | --version DESCRIPTION
grog reads the input (file names or standard input) and guesses which of the groff(1) options are needed to perform the input with the groff program. The corresponding groff command is usually displayed in standard output. With the option --run, the generated line is output into standard error and the generated groff command is run on the standard output. OPTIONS
The option -v or --version prints information on the version number. Also -h or --help prints usage information. Both of these options automatically end the grog program. Other options are thenignored, and no groff command line is generated. The following 3 options are the only grog options, -C this option means enabling the groff compatibility mode, which is also transfered to the generated groff command line. --ligatures this option forces to include the arguments -P-y -PU within the generated groff command line. --run with this option, the command line is output at standard error and then run on the computer. --warnings with this option, some more warnings are output to standard error. All other specified short options (words starting with one minus character -) are interpreted as groff options or option clusters with or without argument. No space is allowed between options and their argument. Except from the -marg options, all options will be passed on, i.e. they are included unchanged in the command for the output without effecting the work of grog. A filespec argument can either be the name of an existing file or a single minus - to mean standard input. If no filespec is specified standard input is read automatically. DETAILS
grog reads all filespec parameters as a whole. It tries to guess which of the following groff options are required for running the input under groff: -e, -g, -G, -j, -J, -p, -R, -s, -t. -man, -mdoc, -mdoc-old, -me, -mm, -mom, and -ms. The guessed groff command including those options and the found filespec parameters is put on the standard output. It is possible to specify arbitrary groff options on the command line. These are passed on the output without change, except for the -marg options. The groff program has trouble when the wrong -marg option or several of these options are specified. In these cases, grog will print an error message and exit with an error code. It is better to specify no -marg option. Because such an option is only accepted and passed when grog does not find any of these options or the same option is found. If several different -marg options are found by grog an error message is produced and the program is terminated with an error code. But the output is written with the wrong options nevertheless. Remember that it is not necessary to determine a macro package. A roff file can also be written in the groff language without any macro package. grog will produce an output without an -marg option. As groff also works with pure text files without any roff requests, grog cannot be used to identify a file to be a roff file. The groffer(1) program heavily depends on a working grog. The grog source contains two files written in different programming languages: grog.pl is the Perl version, while grog.sh is a shell script using awk(1). During the run of make(1), it is determined whether the system contains a suitable version of perl(1). If so, grog.pl is transformed into grog; otherwise grog.sh is used instead. EXAMPLES
* Calling grog meintro.me results in groff -me meintro.me So grog recognized that the file meintro.me is written with the -me macro package. * On the other hand, grog pic.ms outputs groff -p -t -e -ms pic.ms Besides determining the macro package -ms, grog recognized that the file pic.ms additionally needs -pte, the combination of -p for pic, -t for tbl, and -e for eqn. * If both of the former example files are combined by the command grog meintro.me pic.ms an error message is sent to standard error because groff cannot work with two different macro packages: grog: error: there are several macro packages: -me -ms Additionally the corresponding output with the wrong options is printed to standard output: groff -pte -me -ms meintro.me pic.ms But the program is terminated with an error code. * The call of grog -ksS -Tdvi grnexmpl.g contains several groff options that are just passed on the output without any interface to grog. These are the option cluster -ksS con- sisting of -k, -s, and -S; and the option -T with argument dvi. The output is groff -k -s -S -Tdvi grnexmpl.g so no additional option was added by grog. As no option -marg was found by grog this file does not use a macro package. SEE ALSO
groff(1), groffer(1) troff(1), tbl(1), pic(1), chem(1), eqn(1), refer(1), grn(1), grap(1), soelim(1) Man-pages of section 1 can be viewed with either $ man name for text mode or $ groffer name for graphical mode (default is PDF mode). groff_me(7), groff_ms(7), groff_mm(7), groff_mom(7), groff_man(7) Man-pages of section 7 can be viewed with either with $ man 7 name for text mode or $ groffer 7 name for graphical mode (default is PDF mode). COPYING
Copyright (C) 1989-2014 Free Software Foundation, Inc. This file is part of grog, which is part of groff, a free software project. You can redistribute it and/or modify it under the terms of the GNU General Public License version 2 (GPL2) as published by the Free Software Foundation. groff is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. The text for GPL2 is available in the internet at GNU copyleft site <http://www.gnu.org/licenses/gpl-2.0.txt>. AUTHORS
Written by James Clark. Maintained by Werner Lemberg <wl@gnu.org>. Rewritten and put under GPL by Bernd Warken <groff-bernd.warken-72@web.de>. Groff Version 1.22.3 10 February 2018 GROG(1)