Off topic:How to use command line arguments in bash?
0
1
Entering edit mode
3.7 years ago
A_heath ▴ 160

Hi all,

As I'm relatively new to bash scripts, I would need some help if you don't mind, please.

I've written a bash script and it is working perfectly on test files. Now, I would like to use command line arguments so I can use this bash script on any other files I want.

For example, I have this line in my script with a test file:

cut -f 1 TEST_FILE.txt > headers.txt

I would like to be able to do something like this in my Linux terminal:

bash script.sh -i input_any_file.txt

And in my script:

cut -f 1 any_file.txt > headers.txt

So how can I use an input file in an argument and "call" this file on the script? If you have any suggestions, I would be happy to hear them ...

Thank you in advance!

shell bash • 599 views
ADD COMMENT
This thread is not open. No new answers may be added
Traffic: 1663 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6