Skip to content

yutaro-sakamoto/extract-bash-command

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This CLI extracts all commands in a given bash script.

Usage

Run extract-bash-command <paths to bash scripts> to extract all commands in the given bash script. To see the help message, run extract-bash-command -h or extract-bash-command --help.

Installation

Manual installation

  • Install Cargo.
  • Install Git.
  • Run git clone https://github.com/yutaro-sakamoto/extract-bash-command to clone this repository,.
  • Run cargo build --release to build this repository.
  • You can have the executable file in target/release/extract-bash-command. Copy it to a directory that $PATH specifies. (e.g. /usr/bin/)

Using pre-built binary for Linux

Visit the release page and download the binary for your environment.

Example

sample.sh

#!/bin/bash
echo hello
export TEST_VAR=HELLO
echo "$(echo $TEST_VAR)"
if [ "hello" = "world" ]; then
    TEST_VAR=WORLD echo $TEST_VAR # echo world
else
    cat <(echo hello | sed s/hello/world/g)
fi

The command

$ extract-bash-command sample.sh

The output

echo 2 1
echo 4 1
echo 4 9
echo 6 20
cat 8 5
echo 8 11
sed 8 24

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published