0

I am trying to run the following:

exec tail CRON_GBOI_INC_AVG_COMPRESS_20140425_18* | grep -i "status of" | awk -F" " '{ print $NF }'

What it does is it tails the file, grep for the line containing the text status of, which will return a string and then return the last character in the string.

However, Tcl always throws the following error:

missing close-bracket or close-brace while compiling that line.

How can I change the code to do what I need to achieve? Is it at all possible with Tcl?

2 Answers 2

1

Tcl's syntax is not the shell's syntax. The conversion of that line would be:

exec tail {*}[glob CRON_GBOI_INC_AVG_COMPRESS_20140425_18*] | \
        grep -i "status of" | awk "-F " {{ print $NF }}

That's to say, the globbing is explicit, the double quotes are round whole words, and the single quotes are changed to braces. (It's also broken over 2 lines with a backslash-newline sequence for clarity.)

Sign up to request clarification or add additional context in comments.

1 Comment

Unfortunately that isn't working for me. This is the error message I get extra characters after close-brace while compiling "exec tail {*}[glob CRON_GBOI_INC_AVG_COMPRESS_20140425_18*] | grep -i "status of" | awk -F" " {{ print $NF }}..." I also tried your syntax of awk "-F " which also doesn't work. `
0

Sirs, As it happens, Tcl string handling may make this easier:-

set stringBack [exec tail [lindex $argv 0] | grep -i "[lindex $argv 1]" ]
set wanted [string index $stringBack end]
puts "stat chr is $wanted" 

.

We run as, say,

./charget /path/to/file 'text hook we choose'

with file and text hook as parameters (quoting the text hook string for handoff to grep insensitive).

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.