Sponsored Content
Full Discussion: file as input for script
Top Forums Shell Programming and Scripting file as input for script Post 57967 by finster on Thursday 11th of November 2004 01:26:16 AM
Old 11-11-2004
file as input for script

how do I use a file (comma seperated) as an input for a script in bin/sh?

e.g.

I have a script that :

Input1=$1
Input2=$2
Input3=$3
Input4=$4

echo "$Input1, $Input2, $Input3,$Input4" (or some other function)

If I have a .csv file which lists many rows of input:

joe,5,john,10
pat,77,tim,88
etc... (Input1,Input2,Input3,Input4)

How do I use this file for the input of what ever I make the script do? The input will be changed frequently, so I would like to just edit the .csv file, and have the script update the info.

Thanks
 

10 More Discussions You Might Find Interesting

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

2. Shell Programming and Scripting

Parshing script using input from a file to another

Hi all As quite newbie in shell scripting i need your help. The case: two files with question mark delimeter: file1.txt: A; B; D; E; file2.txt: a,antonis,red; b,maria,green; c,george,blue; d,jack,red; e,Helen,yellow; k,konstantin,black; I need an effiecient way of parsing while it... (2 Replies)
Discussion started by: forumsgr
2 Replies

3. Shell Programming and Scripting

Need script to take input from file, match on it in file 2 and input data

All, I am trying to figure out a script to run in windows that will allow me to match on First column in file1 to 8th Column in File2 then Insert file1 column2 to file2 column4 then create a new file. File1: 12345 Sam 12346 Bob 12347 Bill File2:... (1 Reply)
Discussion started by: darkoth
1 Replies

4. Shell Programming and Scripting

input file names to a script

What is a more efficient way to read files into a script? I don't want to hard code the file names like below: for file in file1 \ file2 do ... done I want to execute the script with a variable number for files for input like below: ./scriptname file1 file2 file3 ...... (3 Replies)
Discussion started by: djehresmann
3 Replies

5. Shell Programming and Scripting

AWK Script to convert input file(s) to output file

Hi All, I am hoping someone can help me with some scripting I need to complete using AWK. I'm trying to process multiple fixed files to generate one concatenated fixed file in a standard format. The Input file is:- aaaa bbbbb ccccc 1 xxxx aaa bbb aaaa bbbbb ccccc 2 abcd aaa CCC... (9 Replies)
Discussion started by: jason_v_brown
9 Replies

6. Shell Programming and Scripting

Direct input to a script from a file

Hi all, I have a script which checks on my jobs that run on some cluster. The script, "script.sh", takes as an input the job-id for the job to checked. Sometimes I have 100s of jobs and I want to check them. I could put these job-ids into a file, each id in its own line. The script would ask... (2 Replies)
Discussion started by: faizlo
2 Replies

7. Shell Programming and Scripting

Input file to bash script

Hi, I have this script Script.sh: #!/bin/sh sed 's,\,,g' input.dat > output .dat But i want to run it witb different files. So i want the input file as an input argument to the script, how could i do that. Running it like this: > Script.sh input.dat (2 Replies)
Discussion started by: Johanni
2 Replies

8. Shell Programming and Scripting

Script to delete files with an input for directories and an input for path/file

Hello, I'm trying to figure out how best to approach this script, and I have very little experience, so I could use all the help I can get. :wall: I regularly need to delete files from many directories. A file with the same name may exist any number of times in different subdirectories.... (3 Replies)
Discussion started by: *ShadowCat*
3 Replies

9. UNIX for Dummies Questions & Answers

Use file name as an input to a script

I know I can obtain the file names in a folder by doing the following. ls | awk '{t=$1; print t}' Rather than print t, I'd like to take the file name as an input to a script like bash-3.00$ more test.sh echo "this is a test" ls -l $1 When I run the script, I put "./test.sh a.out" and... (5 Replies)
Discussion started by: learnix
5 Replies

10. Shell Programming and Scripting

Script does not read input file

Hi everyone, I have problems with this script. This script should check for a folder for each server in the list of the list.txt file. The script only checks the first host, and then exits, why? #!/bin/bash file='/etc/list.txt' while read line; do echo $line if ssh root@$line "stat /var >... (2 Replies)
Discussion started by: nashrik
2 Replies
escape(1)							Mail Avenger 0.8.3							 escape(1)

NAME
escape - escape shell special characters in a string SYNOPSIS
escape string DESCRIPTION
escape prepends a "" character to all shell special characters in string, making it safe to compose a shell command with the result. EXAMPLES
The following is a contrived example showing how one can unintentionally end up executing the contents of a string: $ var='; echo gotcha!' $ eval echo hi $var hi gotcha! $ Using escape, one can avoid executing the contents of $var: $ eval echo hi `escape "$var"` hi ; echo gotcha! $ A less contrived example is passing arguments to Mail Avenger bodytest commands containing possibly unsafe environment variables. For example, you might write a hypothetical reject_bcc script to reject mail not explicitly addressed to the recipient: #!/bin/sh formail -x to -x cc -x resent-to -x resent-cc | fgrep "$1" > /dev/null && exit 0 echo "<$1>.. address does not accept blind carbon copies" exit 100 To invoke this script, passing it the recipient address as an argument, you would need to put the following in your Mail Avenger rcpt script: bodytest reject_bcc `escape "$RECIPIENT"` SEE ALSO
avenger(1), The Mail Avenger home page: <http://www.mailavenger.org/>. BUGS
escape is designed for the Bourne shell, which is what Mail Avenger scripts use. escape might or might not work with other shells. AUTHOR
David Mazieres Mail Avenger 0.8.3 2012-04-05 escape(1)
All times are GMT -4. The time now is 04:56 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy