|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | 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 and shell scripting languages here. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
What's the command syntax for stripping out the tar.gz file extension in a bash command line (not script file). Thanks!
prompt/> ls *.tar.gz | <what comes here?> |
| Sponsored Links | ||
|
|
#2
|
|||
|
|||
|
Thank you!
|
| Sponsored Links | ||
|
|
#3
|
||||
|
||||
|
How about using
sed to remove the extension and print: Code:
ls | grep tar.gz | sed 's/\.tar\.gz//g' or simply: Code:
ls *.tar.gz | sed 's/\.tar\.gz//g' or using parameter substitution: Code:
for file in *.tar.gz; do echo "${file%.tar.gz}"; doneLast edited by Yoda; 02-26-2013 at 05:45 PM.. Reason: correction: missed first dot |
|
#4
|
|||
|
|||
|
Another variation on bipinajith's theme: Code:
ls | sed -n '/\.tar\.gz$/s///p' Regards, Alister |
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Conundrum - Flexible way to strip extension | Spadez | Shell Programming and Scripting | 3 | 07-15-2012 09:17 AM |
| Bash - Loading a command's output line by line into an array | Azrael | Shell Programming and Scripting | 4 | 09-20-2011 04:42 AM |
| Bash script to delete file input on command line | animesharma | UNIX for Dummies Questions & Answers | 1 | 07-21-2011 04:27 AM |
| Strip one line from 2 blank lines in a file | tipsy | Shell Programming and Scripting | 6 | 06-23-2008 08:14 AM |
|
|