On the same topic I would like to add, sometimes we run a command and we want to copy the command we just ran onto clipboard. For that I have a solution. In the same way create another bash file and put this piece of code.
#!/usr/bin/bash history | tail -2 | head -1 | awk '{print $2}' | xclip -selection clipboard
Make it executable in the same way as shown above. If you want to access the file anywhere from the terminal just put it in /bin/ directory.
/bin/
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
On the same topic I would like to add, sometimes we run a command and we want to copy the command we just ran onto clipboard. For that I have a solution. In the same way create another bash file and put this piece of code.
Make it executable in the same way as shown above. If you want to access the file anywhere from the terminal just put it in
/bin/
directory.