![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| AIX AIX is IBM's industry-leading UNIX operating system that meets the demands of applications that businesses rely upon in today's marketplace. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| what is the distinguish between gmake and make? | robin.zhu | High Level Programming | 10 | 10-10-2008 03:43 AM |
| How to get file extension | shirleyeow | Shell Programming and Scripting | 17 | 01-17-2008 05:40 AM |
| Stripping out the extension of a file name | ramky79 | Shell Programming and Scripting | 2 | 12-27-2006 11:25 AM |
| default extension of file | rujupriya | UNIX for Dummies Questions & Answers | 2 | 05-17-2006 07:49 AM |
| One Last Question about Core Files (distinguish) URGENT | TRUEST | Shell Programming and Scripting | 2 | 02-18-2003 01:14 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
distinguish the extension of a file
Hello,
In a script shell, I have a variable containing the name of a file and I would like to distinguish the name from the extention of the file. For example, the file 'myfile.txt' is in a variable called $VAR. How can I obtain 2 variables, one with 'myfile' and the other with 'txt' ? Thank you |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
Script test
#!/bin/ksh name=$1 pre=`echo $name | cut -f 1 -d .` pst=`echo $name | cut -f 2 -d .` echo $pre echo $pst To run type ./test test.txt Output test txt |
|
#3
|
||||
|
||||
|
Or...
Code:
VAR='myfile.txt'
pre=${VAR%.*}
pst=${VAR##*.}
|
||||
| Google The UNIX and Linux Forums |