linux-admin.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Cutting
@ 2005-12-10 23:32 MARG
  2005-12-10 23:51 ` Cutting Adrian C.
  2005-12-11  8:50 ` Cutting Glynn Clements
  0 siblings, 2 replies; 3+ messages in thread
From: MARG @ 2005-12-10 23:32 UTC (permalink / raw)
  To: linux-admin

Hi,

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

Only has one dots before the "tar.gz".
MySQL has two.

Any help would be apreciated.

Warm regards,
Mário Gamito
-
To unsubscribe from this list: send the line "unsubscribe linux-admin" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Cutting
  2005-12-10 23:32 Cutting MARG
@ 2005-12-10 23:51 ` Adrian C.
  2005-12-11  8:50 ` Cutting Glynn Clements
  1 sibling, 0 replies; 3+ messages in thread
From: Adrian C. @ 2005-12-10 23:51 UTC (permalink / raw)
  To: linux-admin

Hello.

root@ludmila:~# ls *tar.gz

NeTraMet43.tar.gz             chkrootkit.tar.gz 
     htb_tools-0.2.5.tar.gz 
live555-latest.tar.gz    mod_fastcgi-2.4.2.tar.gz  tcpdump-3.9.1-096.tar.gz
Smarty-2.6.8.tar.gz 
clamav-0.87.1.tar.gz    iftraf-1.0.tar.gz 
ltraf-0.2.0.tar.gz       phpshell-latest.tar.gz    tcptrace-6.6.7.tar.gz
Template-Toolkit-2.14.tar.gz 
exponent-0.95.0.tar.gz  knocker-0.7.1.tar.gz 
ltraf-0.2.1-pre1.tar.gz  stak-1.0b1.tar.gz         teapop-latest.tar.gz

root@ludmila:~# ls *tar.gz | awk -F".tar" '{print $1}'
NeTraMet43
Smarty-2.6.8
Template-Toolkit-2.14
chkrootkit
clamav-0.87.1
exponent-0.95.0
htb_tools-0.2.5
iftraf-1.0
knocker-0.7.1
live555-latest
ltraf-0.2.0
ltraf-0.2.1-pre1
mod_fastcgi-2.4.2
phpshell-latest
stak-1.0b1
tcpdump-3.9.1-096
tcptrace-6.6.7
teapop-latest


Enjoy.

--Adrian.


At 01:32 AM 12/11/2005, MARG wrote:
>Hi,
>
>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
>
>Only has one dots before the "tar.gz".
>MySQL has two.
>
>Any help would be apreciated.
>
>Warm regards,
>Mário Gamito
>-
>To unsubscribe from this list: send the line "unsubscribe linux-admin" in
>the body of a message to majordomo@vger.kernel.org
>More majordomo info at  http://vger.kernel.org/majordomo-info.html


-
To unsubscribe from this list: send the line "unsubscribe linux-admin" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Cutting
  2005-12-10 23:32 Cutting MARG
  2005-12-10 23:51 ` Cutting Adrian C.
@ 2005-12-11  8:50 ` Glynn Clements
  1 sibling, 0 replies; 3+ messages in thread
From: Glynn Clements @ 2005-12-11  8:50 UTC (permalink / raw)
  To: MARG; +Cc: linux-admin


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@gclements.plus.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2005-12-11  8:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-12-10 23:32 Cutting MARG
2005-12-10 23:51 ` Cutting Adrian C.
2005-12-11  8:50 ` Cutting Glynn Clements

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).