Skip to content
Advertisement

Retrieve string between characters and assign on new variable using awk in bash

I’m new to bash scripting, I’m learning how commands work, I stumble in this problem,

I have a file /home/fedora/file.txt

Inside of the file is like this:

JavaScript

What I wanted is to retrieve words between “[” and “]”.

What I tried so far is :

JavaScript

I can print the words between “[” and “]”.

Then I wanted to put the echoed word into a variable but i don’t know how to.

Any help I will appreciate.

Advertisement

Answer

Try this:

JavaScript

or

JavaScript

or complete

JavaScript

or with an array:

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement