Category "shell"

How to declare a var in bash without it replacing a var in a different file

I have 2 files file1 and file2. Inside file1 I declare a var, x=1. In file2 I make a var x=2. If I run file one then file two, and then in the shell echo x, I g

How to override fish_prompt, keeping the styles from the applied theme?

I installed fish shell, installed few themes. Applied the theme "agnoster", all good is pretty but I want fish_prompt to override the original one and keep the

macOS Terminal: `ls` sorts results with capitalised names first

How can I fix this default sorting behaviour for ls in the macOS Terminal? I want the results to be case-insensitive and alphabetised. Here is an example to il

How to check a public RSA key file

Inside a shell script I want verify public RSA file. All I want to do is that find a way to check this file is a genuine public key file, nothing else. Can I a

Replace tags in text file using key-value pairs from JSON file

I am trying to write a shell script that can read a json string, decode it to an array and foreach through the array and use the key/value for replacing strings

Automate mysql_secure_installation with echo command via a shell script

I am trying to automate mysql_secure_installation script with automated response. My code is as follows : echo "& y y abc abc y y y y" | ./usr/bin/mysql_se

^U does not kill despite stty claims

problem: ctrl+U will not kill my terminal program. details: Here are my results from ssty --all: speed 38400 baud; rows 24; columns 80; line = 0; intr =

How to create folder and cd into it with one command

I forget a command,could someone tell me? for example, $ makdir project-one-business-dev-2 $ cd project-one-business-dev-2 I don't want to type project's na

Checking if the string is in proper format in Shell Scripting

I am trying to check if the string is in format in shell script. below is the code i am trying and the output i want to get. Format: <datatype>(length,len

Remove percentage printf and shell

I'm beginning to learn the shell commands. And I don't know how to remove the percent character in the end. Example: printf poo shows poo% I'm on mac and I us

"source" command on mac

I have a .bashrc file on Mac OS in which I set some aliases. After I make it and I type source .bashrc, the aliases work perfectly. However if open another shel

Increment variable value by 1 (shell programming)

I can't seem to be able to increase the variable value by 1. I have looked at tutorialspoint's Unix / Linux Shell Programming tutorial but it only shows how to

replace special character [ and ] including . using sed

I would like to replace the [sample]. with space in all my document.Could someone let me know how can I do this.I tried the below command but it doesn't work.th

Fish shell - advanced control flow

Normally, fish shell processes commands like this: 1 && 3 (2) This is perfectly useful and it mirrors the order of execution that I would want most of

Shell script not running via crontab, but runs fine manually

I have a script that checks if the PPTP VPN is running, and if not it reconnects the PPTP VPN. When I run the script manually it executes fine, but when I make

Docker compose create kafka topics

Problem: Cannot create topics from docker-compose. I need to create kafka topics before I run a system under test. Planning to use it as a part of the pipeline,

How to run functions and local resources over SSH in a shell script

I have a shell script file like this: #!/bin/bash CONF_FILE="/tmp/settings.conf" #settings.conf contains OS_NAME="Caine Linux" source $CONF_FILE display_os_n

What is the difference between p and P in sed?

Can anyone explain what is the difference between p and P in Sed? Suppose I want to print lines containing gmail in the below file using both p and P give the

python script to open tera term application and sending keys

I am trying to use Python script to run Tera Term application to open console for Serial port communication and i am sending some commands/keys like {Enter}

How to read a specific value in PLIST file in terminal

I'm trying to access a specific property in a plist file on my MAC OS, but the name of that property has a space in it and I cannot access it. here is the reque