# Why hidden script will not come up?

I have just setup a hidden shell script named ~/source/.myfuncs. The source directory also has another directory called corp_phones. I am trying to get the hidden script .myfuncs to sort the corp_phones directory by typing at the shell prompt . .myfuncs the corp_phones directory does not come up. Instead a get a thes message at the prompt:

$sort_dept sort: open failed: +4: No such file or directory  This is how the hidden .myfuncs script is setup in the vi editor: sort_name() { sort +1 -t: corp_phones } sort_date() { sort +6 -t: corp_phones } sort_dept() { sort +4 -t: corp_phones }  The file I want to sort is corp_phones which is also in the source directory. Once again I setup the hidden script in the source directory. edit retag close merge delete ## 2 Answers Sort by » oldest newest most voted Use the following code is your ".myfuncs" script. #!/bin/bash sortname() {  sort +1 -t: corpphones sortname "$@"


}

sortdate()

{

    sort +6 -t: corpphones

sortdate "$@"  } sortdept() {  sort +4 -t: corpphones sortdept "$@"


}

more

I used your script but when I try to run the script in memory for example . .myfuncs and then try to test the script by typing: sort_dept . I receive an error bash: /.myfuncs: No such file or directory

Don't type: /.myfuncs That will try to run a script called .myfuncs in your / directory.

You want instead to do either: 1. cd ~/source; ./.myfuncs or 2. ~/source/.myfuncs

The first option first changes directory to your "source" dir, and it then runs the script from within that dir. The second option refers specifically to the script and thus can be run from any dir.

You may also want to make sure that your script is executable byt doing the following: chmod +x ~/source/.myfuncs

more