The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
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 10:58 PM
How to get file extension shirleyeow Shell Programming and Scripting 17 01-17-2008 08:40 AM
remove file extension prvnrk Shell Programming and Scripting 12 08-05-2007 07:46 AM
filename extension check - regular expression devs Shell Programming and Scripting 4 03-02-2007 03:01 PM
Script to check for a file, check for 2hrs. then quit mmarsh UNIX for Dummies Questions & Answers 2 09-16-2005 03:46 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 12-27-2006
mahalakshmi mahalakshmi is offline
Registered User
  
 

Join Date: Nov 2006
Posts: 38
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
  #2 (permalink)  
Old 12-27-2006
sharifhere sharifhere is offline
Registered User
  
 

Join Date: Dec 2006
Posts: 16
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 (permalink)  
Old 12-27-2006
mahalakshmi mahalakshmi is offline
Registered User
  
 

Join Date: Nov 2006
Posts: 38
Thanks sharif. Can u explain me about this cut command. What does f2 and d mean?.
  #4 (permalink)  
Old 12-27-2006
aju_kup aju_kup is offline
Registered User
  
 

Join Date: Jul 2006
Posts: 189
echo a.b.xls | awk -F"." '{ print $NF }'

it will alway give you extension whether file name contain more than 1 dot (.)


------------------
Ajay
  #5 (permalink)  
Old 12-27-2006
sharifhere sharifhere is offline
Registered User
  
 

Join Date: Dec 2006
Posts: 16
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 (permalink)  
Old 12-27-2006
Glenn Arndt's Avatar
Glenn Arndt Glenn Arndt is offline Forum Advisor  
Anomalous Lurker
  
 

Join Date: Feb 2006
Location: Indianapolis, IN
Posts: 255
Using ksh built-in:
Code:
file="foo.bar.baz.quux"
echo ${file##*.}

Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 06:05 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0