Skip Navigation

InitialsDiceBearhttps://github.com/dicebear/dicebearhttps://creativecommons.org/publicdomain/zero/1.0/„Initials” (https://github.com/dicebear/dicebear) by „DiceBear”, licensed under „CC0 1.0” (https://creativecommons.org/publicdomain/zero/1.0/)B
#!/bin/bash

Members
0
Posts
8
Created
3 yr. ago

A community to discuss about Bash.

Bash is a Unix shell and command language written by Brian Fox for the GNU Project as a free software replacement for the Bourne shell. The shell's name is an acronym for Bourne-Again SHell, a pun on the name of the Bourne shell that it replaces and the notion of being "born again".

Keep discussion limited to Bash and projects around it. Feel free to share resources, self-projects, tutorials or any other cool stuff related to Bash.

Icon Attribution : Free Software Foundation, FAL, via Wikimedia Commons.

🌉 bridged from !bash@programming.dev by Tidepool

Terminal Tower of Hanoi, in Bash

Neglected !! party tricks

Everybody knows about using !! to add sudo to your previous command, but there are a couple other things I constantly use it for. So this is just a little PSA in case it never occured to you:

1. grep results

Say I want to search a bunch of files for a string, and then open all files containing that string in my editor. I want to check the search results first, and I never get the exact search correct on my first try anyway, so I'll run a series of commands that might look like...

 
grep -rn . -e "mystring"
...
grep -rn . -e "my.\?string"
...
grep -Rni . -e "my.\?string"
...

Checking the results each time, until I have exactly the set of files that I want. Here's the trick: now add the "-l" flag to grep to get just the file paths:

 
grep -Rnil . -e "my.\?string"

Now when you use !!, you'll get all those filenames. Therefore we can just do vim -p $(!!) to get all those files opened in tabs in vim.

2. with which

Sometimes I want to read or edit a script that's on my computer. To find it, I run which some-command. This confirms that it exists under that name, and that it's an actual script and not an alias or shell function. Now, we can just use vim $(!!) or cat $(!!) or whatever to open it.

OC by @drayva@lemmy.ml

Is it possible to debug a bash script using a debugger in attached mode? For debugging scripts on the host machine and scripts inside a docker container?

I was able to setup a debugger using a launch mode using Visual Studio Code with the Bash Debug extension. Is it possible to setup the debugger in VSCode to be able to debug a bash script using a attach debug mode?

For debugging scripts on the host machine and scripts inside a docker container?