0

I am trying to export some string variables from txt file.

file.txt

ERROR_NOT_SUPPORTED_ARCH_MSG='ERROR: Unknown arch' ERROR_NOT_SUPPORTED_OS_V_MSG='ERROR: Not supported os version'

$ source file.txt
$ export $(cut -f 1 file.txt)

and I am getting error like -

export: `arch'': not a valid identifier

So the question is if it is possible to export string variable with white spaces? What is the proper way to do it?

5

Try with :

cut -d= -f1

compare :

CD > cut -d= -f1 file1.txt 
ERROR_NOT_SUPPORTED_ARCH_MSG
ERROR_NOT_SUPPORTED_OS_V_MSG
CD > cut  -f1 file1.txt 
ERROR_NOT_SUPPORTED_ARCH_MSG='ERROR: Unknown arch' 
ERROR_NOT_SUPPORTED_OS_V_MSG='ERROR: Not supported os version'
  • -d= use = as delimiter
  • 1
    @Rokas.ma It would be pollite since answer solves your problem to accept the answer. – George Vasiliou Jan 25 '17 at 13:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.