Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
why on earth have you called it test.sh when it's not a shell script???
Personally I would make it a proper shell script, and just pipe the passwd file within the script, and not bother with a specific awk script, as it's pretty tiddly.
You already have the interpreter at the top of the file so you can simply call it with:
Code:
./test.sh /etc/passwd
I agree I would change the extension in this case as it is not a shell script but an awk one ... maybe test.awk
As for the file, if you do not include a file as an argument it will think you want the script applied to standard input, which will obviously not work.
You already have the interpreter at the top of the file so you can simply call it with:
Code:
./test.sh /etc/passwd
I agree I would change the extension in this case as it is not a shell script but an awk one ... maybe test.awk
As for the file, if you do not include a file as an argument it will think you want the script applied to standard input, which will obviously not work.
I agree with you grail, But I want to include /etc/passwd inside the script.
I think you may be victim of an old trap that I fell into many years ago.
You cannot call a script "test" if you want to execute it by name. test.sh or test.awk is ok, but test is a built in shell command, which will always take precedence over execution of a script.
I think you may be victim of an old trap that I fell into many years ago.
You cannot call a script "test" if you want to execute it by name. test.sh or test.awk is ok, but test is a built in shell command, which will always take precedence over execution of a script.
I would like to execute the script as
Code:
./test
without /etc/passwd as arguments.
I think you need to re-read my post ... I wasn't saying I couldn't do it, but rather that as far as I know what you want is not possible, from the single script (obviously whk's suggestion will work)
Try reading this page. It is part of the link I gave you previously
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.