I recently switched to another working machive and faced a problem when I work with Cyrillic. My Bash script gets new messages from an application and works with them. However the messages are mostly written in Cyrillic and I get results like “u043fu0440u0438u0432u0456u0442” On my old system that …
Tag: bash
Shell: how to create a list variable from several args
I have shell script that runs a cli command with 3 or more args, i can’t specify in advance the number of args that will be passed to the script. i tried to replace Args=[$3,$4,….] by Args=[${@:3}] but the arguments are not comma-separated. Answer Change the value of IFS inside the command substit…
Why is /etc/profile.d only used at SSH login?
The use of /etc/profile.d is confusing to me. I can put a file in there for example with contents and when I logon the the machine using SSH MYVAR has a value. This machine is a Ubuntu desktop, when I logon using ordinary login and start a terminal MYVAR has no value. I don’t understand why this should …
Modify config files with sed in bash
I am trying to set net.ipv4.ip_forward to 1 in /etc/sysctl.conf.The following works fine but it sure missing some edge cases For e.g if the sysctl.conf contain any one of the following it won’t match #net.ipv4.ip_forward=1 ##net.ipv4.ip_forward=1. Is there a more reliable way to modify settings in confi…
How do I grab console output from a program running in a screen session?
I’m currently in the process of hacking together a bit of bash and python3 to integrate my Minecraft server with my friends Discord. I managed to power through most of the planned features with nary a hitch, however now I’ve gotten myself stuck halfway into the chat integration. I can send message…
How to run linux command before starting up git bash terminal
I am working with Docker on my windows machine via git bash. Since git bash does not record the current status on closing, I need to set some environment variables related to Docker every time when I start a new terminal. The command I would like to run before start-up is: Or better yet, have a bash script in…
Script takes parameters from the previous run
I am using docker container that runs Alpine Linux.It runs some bash script async The first time it runs it seems it does nothing it should write to some database but when I run it second time It does work but it use parameters from the previous run i.e param1 and param2. Without &>/dev/null &disow…
Amazon CLI bash script on Ubuntu 16.04, “unexpected operator” on if statements (syntax looks correct)
I’m trying to troubleshoot issues I’m having with an Amazon CLI backup script that’s running on Ubuntu Server 16.04. When I run the script manually I see that my if statements throw errors. Per request I’ve reduced my example to be minimal and verifiable. This script was running on ano…
Ubuntu bash script grepping and cutting on first column
I am trying to implement a bash script that will take the piped input and cut the first column and return a total. The difference is that the cut is not from a file, but from the piped input. For example: Basically, in my scenario the first column will always be from the passed input. Example usuage is: data.…
Shell script to list unformatted disks (partitions)
I’m looking to create a script that lists the unformatted partitions/disks in Linux OS. I couldn’t find a reliable way of listing the unformatted disks / partitions. I tried to use lsblk –output NAME,FSTYPE,MOUNTPOINT | grep “sd” which outputted: The names which do not have mount…