Re: Cutting

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



MARG wrote:

> Hide like to extract the name and file verion of a tarball from its file
> name in a bash script.
> 
> Example: mysql-5.1.15.tar.bz2
> 
> I want to get only the "mysql-5.0.15" part.
> 
> How can i get this.
> Note: the number of dots, varies.
> Example: qmail-1.03.tar.gz

If the name is in a variable, e.g. $file, then:

	$ file="qmail-1.03.tar.gz"
	$ base="${file%.tar.gz}"
	$ echo "$base"
	qmail-1.03

-- 
Glynn Clements <glynn@xxxxxxxxxxxxxxxxxx>
-
: send the line "unsubscribe linux-admin" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Newbie]     [Audio]     [Hams]     [Kernel Newbies]     [Util Linux NG]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Device Drivers]     [Samba]     [Video 4 Linux]     [Git]     [Fedora Users]

  Powered by Linux