I am on debian 9. I have a problem to check the password of a linux user in my scripts. I realized that the different linux tools for creating and modifying a user password gave results of different pattern in /etc/shadow To create a user I have in /etc/shadow In another script I want check the password input…
Tag: bash
how to print lines with specific column matching members of array in bash
How to print lines when the first column matching members of array(“12” or “34” or “56”)? Add Also, how to print lines when the first column exactly matching members of array(“12” or “34” or “56”)? Answer You could use bash to interpolate…
Printf tab character as hex
In a restricted shell i have only access to execute printf (no awk, hexdump, xxd, …), so i used this script to print a file as hex: issue: last line (printf %02x ‘${a:$i:1}) does not work for some character like s,r,n,t,… i handle space character with (printf “%X” ‘ ‘…
LINUX: How to softlink specific files in all subdirectories
I want to create soft links (ln -s) to folder2 of all the files that contain *foo* in its name, and can be found in some or all the subdirectories of folder1. I’ve tried it with for, find, and find -exec ln, and a combination of them, but all I get is a broken link named *foo* or a link
get user input in awk script and update it in file
I have a students.txt (RollNo, Name, IDU, CGPA), If Roll number exists prompt the user to change the IDU and CGPA and update the same in the file named “Student.txt” I made the following script: now I need help in taking user input for IDU and CGPA values and update the students.text file with that values aga…
Bash Read CSV value from Variable in Bash
So in a script I have a variable that changes each time the script is run. The variable is IP_PING. It is basically a list of if address seperated by commas. I want the script to take each ip addess in the csv variable and ping it. The example below works fine if I only have one ip address in
Assigning variable to a variable inside if statement
I am trying to assign a variable from a prompt input choice with no luck. If the user inputs 1, I want target_db_name = “database2”. My code: I have tried creating another if statement with no luck. Answer if $target_db = “1” then won’t work, because what follows if must be a com…
Bash – if statement not automatically operating
I’m having a very odd problem with a bash script, written on Ubuntu 17.04 machine. I have a txt file that contains information about people in this fashion: number name surname city state With these infos I have to create an organization system that works by state. For example, with a list like this 123…
How To Substitute Piped Output of Awk Command With Variable
I’m trying to take a column and pipe it through an echo command. If possible, I would like to keep it in one line or do this as efficiently as possible. While researching, I found that I have to use single quotes to expand the variable and to escape the double quotes. Here’s what I was trying: But…
How do I replace a string at an undetermined location in a .txt file with a Shell script?
I’m writing a Shell script using Bash to convert a Robot Framework resource file from Windows to Linux. The contents of the Resource file itself are not important, but here is the required “minimal, complete, and verifiable example”. beep is a typeless empty file used to test a site’s …