Quickly creating a shell script

Suppose you want to create and run a short script. It’s often faster not to bother opening up a text editor. Instead, use shell history to write a file, then chmod and execute it:


$ cat > /tmp/me.py
#!/usr/bin/env python
print('hello world')
$ chmod a+x !$
chmod a+x /tmp/me.py
$ !$
/tmp/me.py
hello world
$

Leave a Reply

Your email address will not be published. Required fields are marked *