Sponsored Content
Top Forums Shell Programming and Scripting Reading from a File and Using as an Input variable Post 302456352 by frans on Friday 24th of September 2010 02:59:31 AM
Old 09-24-2010
I would add an if statement to operate only on lines containing given parameter:
bash code:
  1. while IFS="=" read $CONST $VARIABLE
  2. do
  3.    if [ "$CONST" = "$1" ]
  4.    then
  5.         ## do whatever with $CONST and $VARIABLE
  6.    fi
  7. done < INPUT_FILE
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Reading input to create a variable in a script?

I would like to prompt for input and then use it as a variable in a script. Something like this. #!/bin/ksh echo "What is your name?: \c" read response echo "Your name is $reply" >file.txt done exit 0 What am I missing? Thanks, (7 Replies)
Discussion started by: darthur
7 Replies

2. Shell Programming and Scripting

Reading Input from File and Duplicates Output

Greetings to all, I would like to read input from a file and make duplications from it with Linux shell. For e.g. Input file ----------- ABC ABB ABA ------------------------------- Output file ------------ ABC ABC ABC ABB ABB (6 Replies)
Discussion started by: noelcantona
6 Replies

3. Shell Programming and Scripting

Script for reading an input file

#!/bin/sh rpt="/export/home/legato/rpt_offsite"/test_eject.tape cat <$rpt while read line do echo $line perform routine done I am trying to read the contents of this file line by line and perform a routine for each line read. The file contents are numbers.. What is wrong with my... (1 Reply)
Discussion started by: gzs553
1 Replies

4. Shell Programming and Scripting

Help reading an input file in KSH

First I' d like to say you guys are awesome. :) I have a word document that I cut and paste into Textpad and it removed all the fancy formatting which is fine with me. I WinScp'd it to the box and and called it inputfile.txt. Opened it in vi and don't see any special characters or stuff that... (2 Replies)
Discussion started by: zilla30066
2 Replies

5. Shell Programming and Scripting

reading input from a file

I am trying to read input for a C program (that expects input from the user) from a file using the shell command: progname < filename but it seems that the program considers the char '<' as the first input, hence causing an "error" in my program. I checked it with another program and it... (2 Replies)
Discussion started by: nadbar
2 Replies

6. Shell Programming and Scripting

Reading specific contents from 1 input files and appending it to another input file

Hi guys, I am new to AWK and unix scripting. Please see below my problem and let me know if anyone you can help. I have 2 input files (example given below) Input file 2 is a standard file (it will not change) and we have to get the name (second column after comma) from it and append it... (5 Replies)
Discussion started by: sksahu
5 Replies

7. Shell Programming and Scripting

awk- reading input file twice

Hello, I've been trying to come up with a solution for the following problem; I have an input file with two columns and I want to print as an output the first column without any changes but for the second column, I want to divide it by its last value. Example input: 1 9 2 10 3 11 4 12 5... (14 Replies)
Discussion started by: acsg
14 Replies

8. UNIX for Dummies Questions & Answers

Help in reading the date from the input file name

Hi, I need to read the date from the input file. The format of the input file is as follows: a_b_c_yyyymmdd.txt I need to read the date(yyyymmdd) part from the name of the input file. Would really appreciate if someone can help me in this regard Thanks a lot. (1 Reply)
Discussion started by: Sunny_teotia
1 Replies

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

10. UNIX for Dummies Questions & Answers

User input while reading from a file

I am not able to capture the user input in this script(bash).There is prompt for user input.Could some one help me capture user input while reading afile? while read line do echo "$i" path1=$line path2=`echo $line|sed s/new_dir/old_dir/` echo "Do you want to replace?";... (4 Replies)
Discussion started by: parijat guh
4 Replies
Tcl_PkgRequire(3)					      Tcl Library Procedures						 Tcl_PkgRequire(3)

__________________________________________________________________________________________________________________________________________________

NAME
Tcl_PkgRequire, Tcl_PkgRequireEx, Tcl_PkgPresent, Tcl_PkgPresentEx, Tcl_PkgProvide, Tcl_PkgProvideEx - package version control SYNOPSIS
#include <tcl.h> CONST char * Tcl_PkgRequire(interp, name, version, exact) CONST char * Tcl_PkgRequireEx(interp, name, version, exact, clientDataPtr) CONST char * Tcl_PkgPresent(interp, name, version, exact) CONST char * Tcl_PkgPresentEx(interp, name, version, exact, clientDataPtr) int Tcl_PkgProvide(interp, name, version) int Tcl_PkgProvideEx(interp, name, version, clientData) ARGUMENTS
Tcl_Interp *interp (in) Interpreter where package is needed or available. CONST char *name (in) Name of package. CONST char *version (in) A version string consisting of one or more decimal numbers separated by dots. int exact (in) Non-zero means that only the particular version specified by version is acceptable. Zero means that newer versions than version are also acceptable as long as they have the same major version number as version. ClientData clientData (in) Arbitrary value to be associated with the package. ClientData *clientDataPtr (out) Pointer to place to store the value associated with the matching package. It is only changed if the pointer is not NULL and the function completed successfully. _________________________________________________________________ DESCRIPTION
These procedures provide C-level interfaces to Tcl's package and version management facilities. Tcl_PkgRequire is equivalent to the package require command, Tcl_PkgPresent is equivalent to the package present command, and Tcl_PkgPro- vide is equivalent to the package provide command. See the documentation for the Tcl commands for details on what these procedures do. If Tcl_PkgPresent or Tcl_PkgRequire complete successfully they return a pointer to the version string for the version of the package that is provided in the interpreter (which may be different than version); if an error occurs they return NULL and leave an error message in the interpreter's result. Tcl_PkgProvide returns TCL_OK if it completes successfully; if an error occurs it returns TCL_ERROR and leaves an error message in the interpreter's result. Tcl_PkgProvideEx, Tcl_PkgPresentEx and Tcl_PkgRequireEx allow the setting and retrieving of the client data associated with the package. In all other respects they are equivalent to the matching functions. KEYWORDS
package, present, provide, require, version Tcl 7.5 Tcl_PkgRequire(3)
All times are GMT -4. The time now is 07:30 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy