LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Blogs
User Name
Password

Notices


Old

Simple idea for a debug verbosity tool on bash scripts

Posted 09-07-2021 at 09:06 AM by the dsc (linux-related notes)
Tags bash, debug

I used to just have lots of "echos" around my scripts printing where it is on a loop or whatever, so I have a better idea of whats happening, often somewhat more clear than with "bash -x", even though that also may help, of course. But the odds are that I'd at some point just leave such debug echos there while the script runs on a daily basis on the background, just helping .xsession-errors to become enormous, for no good reason, since it's working and I'm not reading it. And...
Member
Posted in Uncategorized
Views 245 Comments 0 the dsc is offline
Old

Simple script-command to mount partitions by label

Posted 08-15-2021 at 02:43 PM by the dsc (linux-related notes)

Largely based on this answer on askubuntu. I hope nothing atrocious results from some situation where it ends up trying to mount something a given user should not, or something. May require tweaking either the script or one's sudo permissions for the commands doing the hard work, I don't know how "default" my settings are.

Code:
#!/bin/bash

echo ${@} | while read input ; do 

for label in /dev/disk/by-label/${input} ; do 

label=$(basename
...
Member
Posted in Uncategorized
Views 365 Comments 0 the dsc is offline
Old

TheOuterLinux Mμse - An interesting way to make a text-based game using catimg and play

Posted 06-22-2020 at 05:30 PM by TheOuterLinux

Cross-posted from: https://theouterlinux.gitlab.io/Publ...CatimgGame.txt
RSS for website version: https://theouterlinux.gitlab.io/Publ...ticleFeed.atom

The following is a BASH script that with the help of 'catimg' and the 'play' command, you can create a classic text-adventure game but have an image shown just above the text. See notes inside of the script.

Code:
#Discussion URL: https://www.reddit.com/r/TheOuterLinux/comments/esgvmf/catimg_and_play_to_for_textbased_games/.compact
...
LQ Newbie
Posted in Uncategorized
Views 308 Comments 0 TheOuterLinux is offline
Old

BASH replace a line in file

Posted 04-05-2020 at 05:20 PM by karanis
Tags bash

sed "s|a dumb string|$lan|g" file.txt

sed "s|#dns_server\t\t10.0.0.1:53|#dns_server 192.168.1.1:53|g" /tmp/baresip_config
LQ Newbie
Posted in Uncategorized
Views 250 Comments 0 karanis is offline
Old

BASH extract fields from string

Posted 04-05-2020 at 05:19 PM by karanis
Tags awk, bash

https://en.wikibooks.org/wiki/Cut

link above have nice examples

Examples of use of similar tools in cut's domain:

echo a b|awk '{print $2}'
Displays "b", separating fields by any number of tabs or spaces. Thus, for awk, "b" is the 2nd field, while for cut -d" ", "b" is the 3rd field.
echo a b|awk '{print $2 $1}'
Displays "ba", preserving the order of the fields as specified....
LQ Newbie
Posted in Uncategorized
Views 285 Comments 0 karanis is offline

  



All times are GMT -5. The time now is 12:22 AM.

Main Menu
Advertisement
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration