appsecben
  • AppSecBen
  • Awesome Links
  • tools
    • grep
    • netstat
    • nmap
    • h8mail
    • sherlock
    • BeEF
    • Wireshark
    • Scapy
    • ffuf
    • wafw00f
    • hCaptcha
    • sn1per
    • WPScan
    • searchsploit
    • Metasploit
    • wget
    • Bash Scripting
    • git
    • Docker
    • VSCode
    • Local web server
    • S3 Bucket
    • JWT
  • Links Úteis
    • Cursos
    • Ferramentas Online
    • Repositórios
    • Articles, Docs, Sites, etc
  • Infra
    • Email
    • DNS
    • Subdomain
    • Ferramentas
    • SSH
  • Tor
    • Links
    • Tor + ProxyChains Config
  • GoLang
    • Cheat Sheet
    • Install
    • Useful Links
    • Packages
    • VSCode
  • Vulns
    • Log4j
Powered by GitBook
On this page
  • Foreach in Cat File
  • Output to cmd and file at the same time
  • Check if command exists

Was this helpful?

  1. tools

Bash Scripting

Foreach in Cat File

# my_script.sh
cat deps.txt | while read line
do
   echo "$line"
done

Output to cmd and file at the same time

# the command output will be displaied to the terminal
# and will be writen in the myfile.txt
my_comand | tee myfile.txt

Check if command exists

command_exists () {
    if [[ $(command -v $1) ]]; then
        return 0
    fi

    return 1
}

if command_exists "MyCommandHere"; then
    echo "MyCommandHere exists"
fi


# real world sample

if command_exists "exa"; then
    alias ls="exa"
fi

PreviouswgetNextgit

Last updated 3 years ago

Was this helpful?