Visit The New, Modern Unix Linux Community

Passing variables/arguments/parameters to commands

Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers Answers to Frequently Asked Questions Passing variables/arguments/parameters to commands
# 1  
Passing variables/arguments/parameters to commands

A good place to start is simple variable passing....
Passing variables from one script to another

The next level is passing a variable into a more complex command such as using a variable in a sed command. There are some simple quoting techniques that are very general. These are mentioned in...
How can I use a variable in sed?

Also awk has a couple of specific ways to handle this...
Passing values out awk.
PASS parameter to AWK
Passing argument to awk script

Doing this with aliases depends on your shell.....
Passing arguments to an alias
alias creation

Last edited by Perderabo; 06-28-2004 at 03:43 PM..

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #628
Difficulty: Easy
In PHP, True !== 1;
True or False?

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Positional Parameters Arguments/Variables when using dot (.)

Hi, Is there a special positional variables for when using the dot (.)? Scripts are as below: $: head -100 x.ksh /tmp/y.ksh ==> x.ksh <== #!/bin/ksh # . /tmp/y.ksh 1234 abcd echo "yvar1 = $yvar1" echo "yvar2 = $yvar2" ==> /tmp/y.ksh <== #!/bin/ksh (2 Replies)
Discussion started by: newbie_01
2 Replies

2. UNIX for Beginners Questions & Answers

Extract values based on parameters passing in arguments

Based on arguments passing in command prompt values should fetch and store in new file. Sample:- sh 10 30 35 45 cat .. cut -c $1-$2,$3-$4 file_name >> file_new ... ... Above sample passing 4 arguments.. but it may differ (sh 10 30 35 45 70 75 ) based on... (1 Reply)
Discussion started by: Jairaj
1 Replies

3. Programming

Passing printf formatting parameters as variables

Hi, I haven't programed in C in a few years. I have been doing a lot of shell scripting, I.E. not really programming anything heavy. :o That said, I have a script that gives hourly usage statistics for our email server. It runs w-a-y to slow as a script for my impatience, and needs to... (7 Replies)
Discussion started by: mph
7 Replies

4. Shell Programming and Scripting

Reading a string and passing passing arguments to a while loop

I have an for loop that reads the following file cat param.cfg val1:env1:opt1 val2:env2:opt2 val3:env3:opt3 val4:env4:opt4 . . The for loop extracts the each line of the file so that at any one point, the value of i is val1:env1:opt1 etc... I would like to extract each... (19 Replies)
Discussion started by: goddevil
19 Replies

5. UNIX for Dummies Questions & Answers

Passing arguments to alias with multiple commands

I have a few aliases set up on AIX servers in my .kshrc file. Some of them contain multiple commands that are piped together. A simple example would be something like this: # alias to list directory contents as root and sort by size. alias lss='sudo ls -l | sort -nbk5' When I call... (5 Replies)
Discussion started by: derndingle
5 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

Optional Parameters/arguments while executing a script.

Hello, I have a shell script "Test.ksh" and I need to pass 8 parameters/arguments while executing the script ./Test.ksh 1 2 3 4 5 6 7 8 Out of these I want first 3 to be compulsory and rest 5 to be optional. Can you suggest the way to do this like and also how to pass these optional... (3 Replies)
Discussion started by: indrajit_u
3 Replies

8. Shell Programming and Scripting

tar cmd how many arguments into parameters of filenames

Hi I would like to use tar cmd in my script. I have a variable with filenames, e.g. 1000 records and I would like to paste its values into tar cmd. For this example I used three elements variable strings. strings="file1.txt file2.txt file3.txt" `tar cf file1.tar $strings` Whether... (1 Reply)
Discussion started by: presul
1 Replies

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

10. Shell Programming and Scripting

passing more than 9 parameters

hi, i am passing around 14 parameters for a script a=$1 b=$2 c=$3 d=$4 e=$5 f=$6 g=$7 h=$8 i=\"${9}\" shift j=\"${1}\" still for j it is displaying the 1st parameter to make it take the 10th parameter (2 Replies)
Discussion started by: dnat
2 Replies

Featured Tech Videos