How can I automate the following using a bash script using word pointers and word modifiers or something similar?
root@server:/tmp
root@server:/tmp
tar -xzf zeromq-2.2.0.tar.gz
root@server:/tmp
cd zeromq-2.2.0
root@server:/tmp/zeromq-2.2.0
When I try something like below, I get errors because word pointers and word modifiers do not work the same in bash scripts, as they do in the shell:
Bash Shell script Example 1:
#!/usr/bin/env bash
wget -q http://download.zeromq.org/zeromq-2.2.0.tar.gz && tar -xzf !$:t && cd !$:r:r
root@server:/tmp
tar (child): Cannot connect to !$: resolve failed
gzip: stdin: unexpected end of file
tar: Child returned status 128
tar: Error is not recoverable: exiting now
Bash Shell script Example 2:
wget -q http://download.zeromq.org/zeromq-2.2.0.tar.gz
tar -xzf !$:t
cd !$:r:r
root@server:/tmp
tar (child): Cannot connect to !$: resolve failed
gzip: stdin: unexpected end of file
tar: Child returned status 128
tar: Error is not recoverable: exiting now
./install.sh: line 11: cd: !$:r:r: No such file or directory
source
share