How to use arguments in a script?



How to use arguments in a script?..

Answer / Vinod Kumar Nimesh

Arguments can be passed to a shell script using command line arguments. To access the arguments within the script, you can use positional parameters such as $1, $2, etc. Here's an example:n```bashn#!/bin/bashnecho 'Argument 1: '$1necho 'Argument 2: '$2"

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Shell Script Interview Questions

How will you list only the empty lines in a file (using grep)?

4 Answers   ANZ,


What is $1 in shell scripting?

1 Answers  


write a non recursive shell script that accepts any number of arguments and prints them in the reverse order

3 Answers  


How to write a function?

1 Answers  


What is the difference between scripting and coding?

1 Answers  


write a shell program to check wheather a given string is pallindrome or not?

4 Answers  


What is subshell?

1 Answers  


Calculate a real number calculation directly from the terminal and not any shell script.

1 Answers  


Write a command sequence to find all the files modified in less than 2 days and print the record count of each.

1 Answers  


why did you apply to shell

3 Answers   Shell,


Why do we use shell scripting?

1 Answers  


What is the significance of the shebang line in shell scripting?

1 Answers  


Categories