Wednesday, October 26, 2022

[SOLVED] not been able to read the output

Issue

I'm not able to read the output from the cat/etc/issue and use it to check if you are using the tested distro for one of my tools

#!/bin/bash
cat /etc/issue 
read distro   
echo $distro
if [[ "$distro" = "Debian GNU/Linux bookworm/sid \n \l" ]];
then
 echo "You are using Debian"
else
 echo "you are not using Debian some things may not work"
fi

Solution

cat and read in your current script are completely independent.

Try read distro </etc/issue instead.

That said, grep is probably better suited to figure out if something contains a certain string, and /etc/os-release seems like a better source for what OS you're running.



Answered By - Gereon
Answer Checked By - Katrina (WPSolving Volunteer)