Avatar of Guddi Yadav
Guddi YadavFlag for United States of America

asked on 

Shell script - File name as a parameter

Hi,
   How do I pass file name as a parameter in shell script ?
Thanks
Shell ScriptingJava* Mac OS

Avatar of undefined
Last Comment
dbauermann
ASKER CERTIFIED SOLUTION
Avatar of Yujin Boby
Yujin Boby
Flag of India image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

I think i mentioned that one of your paths looked wrong in a previous question. Maybe that's the problem. afaicr it began /Downloads
Avatar of noci
noci

Inside the script you can refer to it. as the variable $1 (first parameter).
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

THIS is what i was referring to above
Avatar of dbauermann
dbauermann
Flag of Brazil image

As Yujin said:

./my_shell_script FILE_NAME_HERE

Open in new window


and in your script use:

FILE=$1
cat $FILE

Open in new window




Java
Java

Java is a platform-independent, object-oriented programming language and run-time environment, designed to have as few implementation dependencies as possible such that developers can write one set of code across all platforms using libraries. Most devices will not run Java natively, and require a run-time component to be installed in order to execute a Java program.

102K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo