Ask Your Question

Why hidden script will not come up?

asked 2012-04-11 13:22:29 -0600

bofdelivery gravatar image

updated 2013-06-03 22:44:47 -0600

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 +1 -t: corp_phones
  sort +6 -t: corp_phones
  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 flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2012-04-11 20:08:37 -0600

BK gravatar image

Use the following code is your ".myfuncs" script.




     sort +1 -t: corpphones

     sortname "$@"




    sort +6 -t: corpphones

    sortdate "$@"




    sort +4 -t: corpphones

    sortdept "$@"


edit flag offensive delete link more

answered 2012-04-17 11:32:24 -0600

the.kid gravatar image

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

edit flag offensive delete link more

Question Tools


Asked: 2012-04-11 13:22:29 -0600

Seen: 199 times

Last updated: Jun 03 '13