User is getting additional ". unmatched" string with returned output of "grep" system command

I am a system admin and I have one user that uses a code that loops over a cell array and tries to find each cell entry in a large file (ex. "start_time ="). The output should return something like "start_time = xxxx.xxxxxx" (where x is some number), and it does, except it also returns ". unmatched" with each search result (ex. " . unatched start_time = xxxx.xxxxxx"). The ". matched" string only shows up for her and works fine for everyother user and it causes issues with the rest of the script. It happens wheather you pass the "grep" command to a unix system using the "evalc", "unix", or "system" commands. It also happens on tested versions of R2014a, R2017a, R2018b, or R2019b. It issue only seems to effect her and no other user and I can't seem to track where the source of the problem is coming from. The "grep" command reutrns the correct output without the additional string characters when used in the Linux system terminal window and only happens when Matlab passes the command to the system. Any ideas on what could be the cause of the additional string characters?

5 Comments

Please do both of these:
  1. show exact code that replicates the problem, and
  2. upload the file used by that code.
"Do you mind sending me an email please to bradley.m.partin@raytheon.com?"
I don't do unpaid private consulting. Feel free to:
  • post the requested data here, and someone will take a look, or
  • engage the services of a professional consulting company, or
  • contact TMW technical support (click on the telephone symbol at the top of this page). Most likely you have a contract that includes full technical support from TMW, you might as well make us of it!
file_path = 'grep_test.txt';
things_to_grep = {'ABCDEF', 'GHIJKL', 'MNOPQR', 'STUVWXYZ', '12345', '67890', 'XxXxX'};
for i = 1:length(things_to_grep)
capture_out = evalc(['!grep "' things_to_grep{i} '" ' file_path]);
switch i
case 1
alpha = capture_out;
case 2
bravo = capture_out;
case 3
charlie = capture_out;
case 4
delta = capture_out;
case 5
echo = capture_out;
case 6
foxtrot = capture_out;
case 7
goose = capture_out;
end
end
This is a representation of the code that is failing.
For every user the code works fine and outputs:
Alpha = ‘ABCDEF = 111.11111’
Bravo = ‘GHIKJL = 222.22222’
Charlie = ‘MNOPQR = 333.33333’
Delta = ‘STUVWXYZ = 444.44444’
Echo = ‘12345 = 555.55555’
Foxtrot = ‘67890 = 666.66666’
Goose = ‘XxXxX = 777.77777’
but for the one user in question, for her it returns:
Alpha = ‘Unmatched . ABCDEF = 111.11111’
Bravo = ‘Unmatched . GHIKJL = 222.22222’
Charlie = ‘Unmatched . MNOPQR = 333.33333’
Delta = ‘Unmatched . STUVWXYZ = 444.44444’
Echo = ‘Unmatched . 12345 = 555.55555’
Foxtrot = ‘Unmatched . 67890 = 666.66666’
Goose = ‘Unmatched . XxXxX = 777.77777’
I don't know why the 'Unmatched .' only shows up for her no mater the Matlab version or machine she uses.
This need to be ran on a Linux machine that has the native 'grep' command built in.
I have no idea why that happens, nor can I test it myself. I doubt that many volunteers on this forum would have a detailed knowledge of that particular combination of MATLAB+system commands.
But as system administrator you can ask TMW technical support: their contact details are at top of this page.

Sign in to comment.

Answers (0)

Categories

Products

Release

R2019b

Asked:

on 24 Aug 2020

Commented:

on 1 Sep 2020

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!