social.gl-como.it

Cerca

Elementi taggati con: bash

#linux #bash #coutils #progress
 
Super impressed by ArgBash, a library for generating code to parse command line arguments in #bash. Well written, easy to use, and generates very correct code that handles nearly any kind of argument your script might need. Came in handy today.


@Gruppo Linux Como
 

Because finding the #GUID of a #Diaspora post sucks:



````
#!/bin/bash

[[ -z "${1}" ]] && {
echo 'usage: dlink ' >&2
exit 1
}
guid=$(
curl -s "${1}.json" \
| jq .guid \
| tr -d '"'
)
printf '/posts/%s\n' "${guid}"
:

eof



````

The syntax highlighting sucks, too…

Caveat: no error checking.

[ #JSON, #CLI, #bash, #useatyourownperil ]
 

Because finding the #GUID of a #Diaspora post sucks:



````
#!/bin/bash

[[ -z "${1}" ]] && {
echo 'usage: dlink ' >&2
exit 1
}
guid=$(
curl -s "${1}.json" \
| jq .guid \
| tr -d '"'
)
printf '/posts/%s\n' "${guid}"
:

eof



````

The syntax highlighting sucks, too…

Caveat: no error checking.

[ #JSON, #CLI, #bash, #useatyourownperil ]
 
Immagine/foto

Pon a prueba tus conocimientos sobre Bash | Cyberhadeshttp://www.cyberhades.com/2017/02/06/pon-a-prueba-tus-conocimientos-sobre-bash/

En cmdchallenge.com podemos encontrar, como su nombre indica, varios retos que debemos resolver usando comandos de Bash.

#bash #cmdhttp://www.cyberhades.com/2017/02/06/pon-a-prueba-tus-conocimientos-sobre-bash/
#bash #cmd
 
A nice little shell trick:

You are all probably familiar with "here documents":
cat <<EOF
line 1
line 2
EOF

This will consider the lines of text from the standard input as input for cat. It is terminated by the special marker that comes after the '<<'. This is handy, for instance, to create text files:
cat <<THEEND >newfile
a line
and another
$variables will be expanded
THEEND

I needed to write an internal document in my company. In it there were instructions for creating a certain configuration file. I wanted to be as user-friendly as possible. I initially wrote just the content of the file and its full path. But later wanted to improve the instructions. Thus wanted to use 'here documents'. But what if the users know their way already (and may have better ideas on the file name, etc.), how do I avoid getting in the way?

The first step is obvious. That file has '#' as a comment marker. Thus I wrote:

# cat <<EOF >/the/full/path
line 1
line 2
EOF

Note the last empty line. When giving instructions to copy and paste to a terminal, you should leave a final empty line for the final press of Enter.

If someone accidentally copies the first line as well, it is still a valid configuration file. But then I thought: Why not make the marker a comment line as well?

# cat <<'#EOF' >/the/full/path
line 1
line 2
#EOF

Done.

#bash #linux #scripts #shell
 
Je viens de créer un dépôt pour mes scripts buku : https://github.com/polo2ro/buku-scripts

Buku: Gestionnaire de signets en ligne de commande pour Linux



https://websetnet.com/fr/buku-command-line-bookmark-manager-linux/

#buku #bash #linux

polo2ro/buku-scripts

buku-scripts - scripts for buku bookmarks
 
Simple & brilliant idea:

https://transfer.sh



Plus they have an onion service.

#Ungoogle #filesharing #bash
 
nuovi vecchi