Skip to main content
Tweeted twitter.com/StackUnix/status/952211984254226433
edited body; edited tags
Source Link
ilkkachu
  • 148.1k
  • 16
  • 268
  • 441

The user can write in my bashBash script a mac address in the following way:

read -p "enter mac-address " mac-address

Now i want to check in an if-statement, if this mac-address matches with a "specific" format. i.e. it should be FF:FF:FF:FF:FF:FF and not FFFFFFFFFFFF. Also the length should be correct: 6x2.

The user can write in my bash script a mac address in the following way:

read -p "enter mac-address " mac-address

Now i want to check in an if-statement, if this mac-address matches with a "specific" format. i.e. it should be FF:FF:FF:FF:FF:FF and not FFFFFFFFFFFF. Also the length should be correct: 6x2.

The user can write in my Bash script a mac address in the following way:

read -p "enter mac-address " mac-address

Now i want to check in an if-statement, if this mac-address matches with a "specific" format. i.e. it should be FF:FF:FF:FF:FF:FF and not FFFFFFFFFFFF. Also the length should be correct: 6x2.

added 2 characters in body
Source Link

The user can write in my bash script a mac address in the following way:

read -p "enter mac-address " mac-adressaddress

Now i want to check in an if-statement, if this mac-adressaddress matches with a "specific" format. i.e. it should be FF:FF:FF:FF:FF:FF and not FFFFFFFFFFFF. Also the length should be correct: 6x2.

The user can write in my bash script a mac address in the following way:

read -p "enter mac-address " mac-adress

Now i want to check in an if-statement, if this mac-adress matches with a "specific" format. i.e. it should be FF:FF:FF:FF:FF:FF and not FFFFFFFFFFFF. Also the length should be correct: 6x2.

The user can write in my bash script a mac address in the following way:

read -p "enter mac-address " mac-address

Now i want to check in an if-statement, if this mac-address matches with a "specific" format. i.e. it should be FF:FF:FF:FF:FF:FF and not FFFFFFFFFFFF. Also the length should be correct: 6x2.

Source Link

How to check if input string matches a specific format?

The user can write in my bash script a mac address in the following way:

read -p "enter mac-address " mac-adress

Now i want to check in an if-statement, if this mac-adress matches with a "specific" format. i.e. it should be FF:FF:FF:FF:FF:FF and not FFFFFFFFFFFF. Also the length should be correct: 6x2.