cancel
Showing results for 
Search instead for 
Did you mean: 

script skill

neocosmic
Occasional Contributor

script skill

1. how check the file extension in the script?

2. what is basename used for?

3. where is ".profile" place usually?
4 REPLIES
Khalid A. Al-Tayaran
Valued Contributor

Re: script skill


Hi,

1- Usually in Linux/UNIX we don't sepcify a file extension. The script is immediately saved with no extension. use ls -l for more details.

2- No info.

3- Under the home directory, example: /home/admin/.profile
John Poff
Honored Contributor

Re: script skill

Hi,

1. If you are wondering if a variable containing a filename has an extension, here is one way to possibly get it using parameter expansion:

f=myfile.txt
b=${f##*.}
echo $b

txt

2. The basename function will take a filename with a path as an argument and will return the filename with all the directory path removed, something like this:

$ basename /somebig/dir/myfile.txt
myfile.txt

3. In your home directory.

JP
Andrew Allen_1
Occasional Visitor

Re: script skill

Usually, the fist line in the script gives the app that it is used for.
#! /bin/ksh
Says use the k shell.
-Although, you don't necessarily need that, you can tell it to run with whatever interepreter you want by prefixing your script with the interepreter...
/bin/ksh script

-If you do include the interpreter in the top line (yes, it looks like a comment), you will need to change the script to be executable.
chmod + x script
(+x means add execuateble for all)

-Other answers given were fine.
Umapathy S
Honored Contributor

Re: script skill

I think you may be trying answers out for a list of questions ??? :).
Your questions were answered, but please spend time to provide points to the people who took some of their time to answer you back. This will encourage all to respond to you back in a good way.



thanks,
Umapathy
Arise Awake and Stop NOT till the goal is Reached!