![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How do i check whether a file has extension? | sunday8 | Shell Programming and Scripting | 2 | 08-29-2008 06:58 PM |
| How to get file extension | shirleyeow | Shell Programming and Scripting | 17 | 01-17-2008 05:40 AM |
| remove file extension | prvnrk | Shell Programming and Scripting | 12 | 08-05-2007 03:46 AM |
| filename extension check - regular expression | devs | Shell Programming and Scripting | 4 | 03-02-2007 12:01 PM |
| Script to check for a file, check for 2hrs. then quit | mmarsh | UNIX for Dummies Questions & Answers | 2 | 09-16-2005 11:46 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
Check file extension
Hi ,
I am FTPing the file. Once the file is FTPied I need to check whether that file currently transferred is of .xls and I need to convert the same to a flat file. What command to use to find the extension of the file?. Thanks Mahalakshmi.A |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
Fiel Extension
Hi Maha,
Prob this shud help u. /scripts/scr-bk-04-dec:>var=temp.cts /scripts/scr-bk-04-dec:>echo $var | cut -d "." -f2 cts /scripts/scr-bk-04-dec:> Thanks, Sharif.S |
|
#3
|
|||
|
|||
|
Thanks sharif. Can u explain me about this cut command. What does f2 and d mean?.
|
|
#4
|
|||
|
|||
|
echo a.b.xls | awk -F"." '{ print $NF }'
it will alway give you extension whether file name contain more than 1 dot (.) ------------------ Ajay |
|
#5
|
|||
|
|||
|
Cut Command
Cut :
Purpose : STrips/Cuts the required part from the passed input text Usage: cut -d "<value> -f <value> or -c <value> -d = Delimiter Seperator using wich u want divide ur text, Like "ABC,DEF" here , can be used as delimiter. -f = field num This is similar to column numbers. Inthe abv example ABC is field 1 and DEF is field# 2 if input is divided using comma. -c = Character cut -c 1,3 this will cut between 1st character to 3rd char. Hope u understood wat i tried say. Thanks, Sharif.S |
|
#6
|
||||
|
||||
|
Using ksh built-in:
Code:
file="foo.bar.baz.quux"
echo ${file##*.}
|
|
#7
|
|||
|
|||
|
Thanks all of you for all your replies. It all worked fine and I am using the command which suits the requirement.
Regards Mahalakshmi.A |
|||
| Google The UNIX and Linux Forums |