Skip to main content
replaced http://unix.stackexchange.com/ with https://unix.stackexchange.com/
Source Link

I have files which are of the following style - these are parametrised configuration files; the values within the #characters are replaced with real values from a database depending on environment.

ABC=#PARAMETER_1#:#PARAMETER_2#
SOMETHING_ELSE=#PARAMETER_1#
SOMETHING_NEW=#PARAMETER_2##PARAMETER_3#

I would like to extract from these files the values between the hash/pound (#) characters, so that I can easily identify the parameters required. There is no standard column width or anything like that, the only standard being that anything between two # characters is replaced with a value from the database.

This is the ideal cleaned, deduped output:

PARAMETER_1
PARAMETER_2
PARAMETER_3

I have seen thisthis question, but the crucial difference is that there can be any number of variables on a particular line in my situation.

I have tagged this question with Bash, but it doesn't have to be, it could be perl etc, it just needs to run from the command line in Unix.

I have files which are of the following style - these are parametrised configuration files; the values within the #characters are replaced with real values from a database depending on environment.

ABC=#PARAMETER_1#:#PARAMETER_2#
SOMETHING_ELSE=#PARAMETER_1#
SOMETHING_NEW=#PARAMETER_2##PARAMETER_3#

I would like to extract from these files the values between the hash/pound (#) characters, so that I can easily identify the parameters required. There is no standard column width or anything like that, the only standard being that anything between two # characters is replaced with a value from the database.

This is the ideal cleaned, deduped output:

PARAMETER_1
PARAMETER_2
PARAMETER_3

I have seen this question, but the crucial difference is that there can be any number of variables on a particular line in my situation.

I have tagged this question with Bash, but it doesn't have to be, it could be perl etc, it just needs to run from the command line in Unix.

I have files which are of the following style - these are parametrised configuration files; the values within the #characters are replaced with real values from a database depending on environment.

ABC=#PARAMETER_1#:#PARAMETER_2#
SOMETHING_ELSE=#PARAMETER_1#
SOMETHING_NEW=#PARAMETER_2##PARAMETER_3#

I would like to extract from these files the values between the hash/pound (#) characters, so that I can easily identify the parameters required. There is no standard column width or anything like that, the only standard being that anything between two # characters is replaced with a value from the database.

This is the ideal cleaned, deduped output:

PARAMETER_1
PARAMETER_2
PARAMETER_3

I have seen this question, but the crucial difference is that there can be any number of variables on a particular line in my situation.

I have tagged this question with Bash, but it doesn't have to be, it could be perl etc, it just needs to run from the command line in Unix.

Tweeted twitter.com/#!/StackUnix/status/212266550479167489
Source Link
Rich
  • 4.7k
  • 10
  • 37
  • 34

Extract marked strings from text file using Bash

I have files which are of the following style - these are parametrised configuration files; the values within the #characters are replaced with real values from a database depending on environment.

ABC=#PARAMETER_1#:#PARAMETER_2#
SOMETHING_ELSE=#PARAMETER_1#
SOMETHING_NEW=#PARAMETER_2##PARAMETER_3#

I would like to extract from these files the values between the hash/pound (#) characters, so that I can easily identify the parameters required. There is no standard column width or anything like that, the only standard being that anything between two # characters is replaced with a value from the database.

This is the ideal cleaned, deduped output:

PARAMETER_1
PARAMETER_2
PARAMETER_3

I have seen this question, but the crucial difference is that there can be any number of variables on a particular line in my situation.

I have tagged this question with Bash, but it doesn't have to be, it could be perl etc, it just needs to run from the command line in Unix.