Skip to content

Instantly share code, notes, and snippets.

@NWuensche
Created April 12, 2023 17:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NWuensche/1de625beadfe49e1e073feaee4e6c870 to your computer and use it in GitHub Desktop.
Save NWuensche/1de625beadfe49e1e073feaee4e6c870 to your computer and use it in GitHub Desktop.
Bash-Script that almost writes itself. To demonstrate that bash scripts are written line by line
#!/bin/sh
#Program that almost writes itself into itself (but not quite), demonstrate that bash is executed line by line rather than whole file
CURR_FILENAME=$0
echo "Hello World"
sed -n '5,6 p' $CURR_FILENAME >> $CURR_FILENAME #Write 4th and 5th line into same file (i.e. echo + sed)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment