Explore >> Select a destination


You are here

kaveh.page
| | purefun.dev
20.2 parsecs away

Travel
| | When in doubt, always consider adding set -e and cd $(dirname $0) at the beginning of a shellscript. Why? Let's find out: When to use cd $(dirname $0) $0 is the currently executing script, so what the command does is to change current directory into the same directory as where the script resides. If you don't do this, any references to other files next to your script will be incorrect if you run the script from another directory.
| | blog.nuculabs.de
20.1 parsecs away

Travel
| | Hello, This challenge is not that hard but it's quite confusing. To solve this challenge very quickly all you have to do is patch it in 2 places and then run it with different arguments until the flags get's spiten out. Here's a sample script that runs the binary 100 times with arguments from 1 to 100 [code language="bash"] printf 'start\n' for i in {1..100} do printf "$i " ./program "$i" | xxd -r -p printf '\n' done printf '\nend\n' [/code]
| | willhaley.com
12.2 parsecs away

Travel
| | This is a trivial example, but is meant to demonstrate how you can pipe arguments to a bash function. #!/usr/bin/env bash lowercase() { # Grab input. declare input=${1:-$(</dev/stdin)}; # Use that input to do anything. echo "$input" | tr '[:upper:]' '[:lower:]' } echo "HELLO there, FRIEND!" | lowercase Which outputs the following. hello there, friend!
| | www.sahilparikh.com
72.2 parsecs away

Travel
| A clean setup is always fun.