Is there any way to execute small bash snippets in the shell?If you don't want to edit a file again and again and test it by executing it again and again (in fact by jumping forth and back between two programs: editor and shell), you might want to execute small code snippets (maybe as strings) in the shell directly.For example testing a regular expression or any part of an if-condition: hi =~ h. OK, the result of this might be obvious, but there are more complicated cases for one, two or three liner.So, none of these ways, because, AFAIK bash -x executes files and eval executes commands only.
Execute bash snippets directly in shell?
bash;shell
You can run it in the shell, for example like:$ for i in $(find /etc -type f); do wc -l $i; doneThis runs through /etc and gives out the line count of each file.Added according your comment:$ if [ hi == hi ]; then echo this is true; fi