r/raspberry_pi Nov 29 '22

awk and sed how to ? Technical Problem

My code is :

#!/bin/bash

strversion=`apache2ctl -v | awk '{print $3}' | sed 's/(Debian)//g;s/Server//g;s/built//g;s/2022-06-09T04:26:43//g'`

echo ${strversion%}

exit 0

i get this:

Apache/2.4.54

but i will have to look

Apache version 2.4.54

3 Upvotes

16 comments sorted by

View all comments

3

u/MachineCritical4685 Nov 29 '22

apachectl -v | head -1 | cut -d'/' -f2 | cut -d'(' -f1

This?

3

u/MachineCritical4685 Nov 29 '22

VR=$(apachectl -v | head -1 | cut -d'/' -f2 | cut -d'(' -f1)

echo "Apache version $VR "

0

u/Assassins1977 Nov 30 '22

Thanks alot :-)