I have a little script that extracts archives, I found it somewhere on the net:
extract () {
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xvjf $1 ;;
*.tar.gz) tar xvzf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) unrar x $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xvf $1 ;;
*.tbz2) tar xvjf $1 ;;
*.tgz) tar xvzf $1 ;;
*.zip) unzip $1 ;;
*.Z) uncompress $1 ;;
*.7z) 7z x $1 ;;
*) echo "don't know how to extract '$1'..." ;;
esac
else
echo "'$1' is not a valid file!"
fi
}
Related Posts:
- How do I prevent accidental rm -rf /*?
- How do I deal with a filename that starts with the hyphen (-) character?
- Bash: No such file or directory?
- How to create a file in Linux from terminal window? [closed]
- Why do you need to put #!/bin/bash at the beginning of a script file?
- How to get the url of the current svn repo?
- “Couldn’t find a file descriptor referring to the console” on Ubuntu bash on Windows
- gzip: stdin: not in gzip format tar: Child returned status 1 tar: Error is not recoverable: exiting now
- Pass a password to ssh in pure bash
- -bash: syntax error near unexpected token `newline’ for display command
- How do I use grep to search the current directory for all files having the a string “hello” yet display only .h and .cc files?
- “sed” command in bash
- Explaining the ‘find -mtime’ command
- How does “cat << EOF" work in bash?
- Pseudo-terminal will not be allocated because stdin is not a terminal
- Extract file basename without path and extension in bash
- Given two directory trees, how can I find out which files differ by content?
- mv: cannot stat error : No such file or directory error
- Pseudo-terminal will not be allocated because stdin is not a terminal
- ./configure : /bin/sh^M : bad interpreter
- Trying to use bash on Windows and got no installed distributions message
- What is the difference between “#!/usr/bin/env bash” and “#!/usr/bin/bash”?
- -bash: fork: Cannot allocate memory
- Is there a “goto” statement in bash?
- Merge / convert multiple PDF files into one PDF
- Bash script: bad interpreter
- How to count lines in a document?
- What does `set -x` do?
- How to get the process ID to kill a nohup process?
- Writing a simple shell in C using fork/execvp
- chmod: changing permissions of ‘my_script.sh’: Operation not permitted
- tar: add all files and directories in current directory INCLUDING .svn and so on
- What does set -e mean in a bash script?
- What does set -e mean in a bash script?
- “find: paths must precede expression:” How do I specify a recursive search that also finds files in the current directory?
- Bash script prints “Command Not Found” on empty lines
- Pipe to/from the clipboard in a Bash script
- Linux Bash: Move multiple different files into same directory
- How do I write stderr to a file while using “tee” with a pipe?
- How to include file in a bash shell script
- How to enable Bash in Windows 10 developer preview?
- What does ‘bash -c’ do?
- bash sh – command not found
- How do I know the script file name in a Bash script?
- How can I sort du -h output by size
- What are the functional differences between .profile .bash_profile and .bashrc
- How to run a command multiple times, using bash shell?
- How to cd into a directory with this name “-2” (starting with the hyphen)?
- How do I sleep for a millisecond in bash or ksh
- What is “-bash: !”: event not found”
- What’s the best way to check if a volume is mounted in a Bash script?
- Keeping a linux process running after I logout
- How do I find the UUID of a filesystem
- Find out symbolic link target via command line
- How to add a timestamp to bash script log?
- How to remove empty/blank lines from a file in Unix (including spaces)?
- Colors in bash after piping through less?
- Linux command line best practices and tips?
- How to run command as user who has /usr/sbin/nologin as Shell?
- How to get pid of just started process
- How to display certain lines from a text file in Linux?
- What’s the reverse DNS command line utility?
- Can you have more than one ~/.ssh/config file?
- SSH from A through B to C, using private key on B [closed]
- How can I fully log all bash scripts actions?
- How to sort ps output by process start time?
- How to apply a filter to real time output of `tail -f `?
- How to remove invalid characters from filenames?
- zcat/gzcat works in linux, not on osx. general linux/osx compatibility
- How do I grep recursively?
- SSH using python script
- Changing the resolution of a VNC session in linux
- X11 forwarding request failed on channel 0
- What is difference between arm64 and armhf?
- standard_init_linux.go:178: exec user process caused “exec format error”
- Using ls to list directories and their total sizes
- make -j 8 g++: internal compiler error: Killed (program cc1plus)
- what does -zxvf mean in tar -zxvf filename?
- Retrieve last 100 lines logs
- Configuring Apache for localhost
- Android – Command not found
- EC2 ssh Permission denied (publickey,gssapi-keyex,gssapi-with-mic)
- WordPress can’t find temporary folder, but folder it’s looking at has correct permissions
- What exactly do the colors in htop status bars mean?
- Showing total progress in rsync: is it possible?
- How to bind MySQL server to more than one IP address?
- What’s the best way of handling permissions for Apache 2’s user www-data in /var/www?
- How to setup passwordless `sudo` on Linux?
- How do I verify the speed of my NIC?
- How to list Apache enabled modules?
- How can I monitor hard disk load on Linux?
- How to add a security group to a running EC2 Instance?
- How bad is it really to install Linux on one big partition?
- How do I extract login history?
- Is it possible to reboot a Linux OS without rebooting the hardware?
- Does the “bs” option in “dd” really improve the speed?
- What solutions exist to allow the use of revision control for server configuration files? [closed]
- Is there a way to do a remote “ls” much like “scp” does a remote copy?
- Dump a linux process’s memory to file
- What is the difference between /sbin/nologin and /bin/false?