Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Search a multi-line shell command output and execute logic based on result Post 303042194 by yogi on Wednesday 18th of December 2019 03:54:11 PM
Old 12-18-2019
Thanks, this works! Smilie

--- Post updated at 09:54 PM ---

A bit of an unrelated question, the snippet mentioned by Scrutinizer works when calling cargo build. If I use a hot-reload tool such as cargo-watch as my initial command, it does not work. I was reading the documents for cargo-watch and it seems to be built on top of watchexec, not sure if that blocks I/O somehow? Does anyone know how I can get the grep command to work with cargo watch? What is stopping it from functioning as intended?
 

10 More Discussions You Might Find Interesting

1. Programming

how to execute multi command???

Hi every one I'm writing C program that do the following: will creat new sample command in unix using C let be the name is do.c, the do must execute more the one command for example do ls ps it will execute ls the ps also I should create a log file the track the command and exit status of... (4 Replies)
Discussion started by: aliG4
4 Replies

2. Shell Programming and Scripting

Use grep result to execute next command

Hi I am trying to run 2 servers using a script one after the other. I start the first one: run.sh -c servername >> jboss_log.txt & Then I have to wait until I see Started message in the log file before I launch the other server. I can't use sleep because I am not sure how long it'll... (5 Replies)
Discussion started by: iririr
5 Replies

3. Shell Programming and Scripting

Joining multi-line output to a single line in a group

Hi, My Oracle query is returing below o/p ---------------------------------------------------------- Ins trnas value a lkp1 x a lkp1 y b lkp1 a b lkp2 x b lkp2 y ... (7 Replies)
Discussion started by: gvk25
7 Replies

4. Shell Programming and Scripting

Multi-line filtering based on multi-line pattern in a file

I have a file with data records separated by multiple equals signs, as below. ========== RECORD 1 ========== RECORD 2 DATA LINE ========== RECORD 3 ========== RECORD 4 DATA LINE ========== RECORD 5 DATA LINE ========== I need to filter out all data from this file where the... (2 Replies)
Discussion started by: Finja
2 Replies

5. Shell Programming and Scripting

Different cmd to execute and based on some pattern parse it and then store result in xlx format

Hi I have a different requirement, I need to run some application on my device from a file app_name.txt one by one which is like this: /usr/apps/email /usr/apps/message /usr/apps/settings after each app while it is running I need to execute again one cmd like ps -ef |grep... (2 Replies)
Discussion started by: Sanjeev Roy
2 Replies

6. Shell Programming and Scripting

Output block of lines in a file based on grep result

Hi I would appreciate your help with this. I have a output file from a command. It is broken based on initial of the users. Exmaple of iitials MN & SS. Under each section there is information pertaining to the user however each section can have different number of lines. MY challenge is to ... (5 Replies)
Discussion started by: mnassiri
5 Replies

7. Shell Programming and Scripting

sed working on command line but file unchanged when execute with Shell script

I have a simple task to replace unix line feed end of line characters with carriage returns. When I run the following “change file in place” sed instruction from the command line all the Line feeds are successfully replaced with Carriage returns. sed -i 's/$/\r/' lf_file.txt But that same... (1 Reply)
Discussion started by: hawkman2k
1 Replies

8. Shell Programming and Scripting

How to execute a command on each line of output from another command?

Hello :) new to bash not to programming. I have an on-going need to change the owning group on sets of files and directories from the one they were created with or changed to on update to the one they need to have going forward. find {target_root} -group wrong_group gets me a newline... (4 Replies)
Discussion started by: naftali
4 Replies

9. Shell Programming and Scripting

Execute command and show result in web page

Hi everyone, I have two question 1- I want to execute command in shell and after execution result show in a web server. (kind of making UI ) e.g. in shell root ~: show list item1 item2 item(n)in web server in a page draw a table and show those items in itno | name... (1 Reply)
Discussion started by: indeed_1
1 Replies

10. UNIX for Beginners Questions & Answers

Merge multi-lines into one single line using shell script or Linux command

Hi, Can anyone help me for merge the following multi-line log which beginning with a " and line ending with ": into one line. *****Original Log***** 087;2008-12-06;084403;"mc;;SYHLR6AP1D\LNZW;AD-703;1;12475;SYHLR6AP1B;1.1.1.1;0000000062;HGPDI:MSISDN=12345678,APNID=1,EQOSID=365;... (3 Replies)
Discussion started by: rajeshlinux2010
3 Replies
watch(n)						       BLT Built-In Commands							  watch(n)

__________________________________________________________________________________________________________________________________________________

NAME
watch - call Tcl procedures before and after each command SYNOPSIS
watch create watchName ?options? watch activate watchName watch deactivate watchName watch delete watchName watch configure watchName ?options watch info watchName watch names _________________________________________________________________ DESCRIPTION
The watch command arranges for Tcl procedures to be invoked before and after the execution of each Tcl command. INTRODUCTION
When an error occurs in Tcl, the global variable errorInfo will contain a stack-trace of the active procedures when the error occured. Sometimes, however, the stack trace is insufficient. You may need to know exactly where in the program's execution the error occured. In cases like this, a more general tracing facility would be useful. The watch command lets you designate Tcl procedures to be invoked before and after the execution of each Tcl command. This means you can display the command line and its results for each command as it executes. Another use is to profile your Tcl commands. You can profile any Tcl command (like if and set), not just Tcl procedures. EXAMPLE
The following example use watch to trace Tcl commands (printing to standard error) both before and after they are executed. proc preCmd { level command argv } { set name [lindex $argv 0] puts stderr "$level $name => $command" } proc postCmd { level command argv retcode results } { set name [lindex $argv 0] puts stderr "$level $name => $argv0= ($retcode) $results" } watch create trace -postcmd postCmd -precmd preCmd OPERATIONS
The following operations are available for the watch command: watch activate watchName Activates the watch, causing Tcl commands the be traced to the maximum depth selected. watch create watchName ?options?... Creates a new watch watchName. It's an error if another watch watchName already exists and an error message will be returned. Options may have any of the values accepted by the watch configure command. This command returns the empty string. watch configure watchName ?options...? Queries or modifies the configuration options of the watch watchName. WatchName is the name of a watch. Options may have any of the following values: -active boolean Specifies if the watch is active. By default, watches are active when created. -postcmd string Specifies a Tcl procedure to be called immediately after each Tcl command. String is name of a Tcl procedure and any extra arguments to be passed to it. Before string is invoked, five more arguments are appended: 1) the current level 2) the cur- rent command line 3) a list containing the command after substitutions and split into words 4) the return code of the com- mand, and 5) the results of the command. The return status of the postcmd procedure is always ignored. -precmd string Specifies a Tcl procedure to be called immediately before each Tcl command. String is name of a Tcl procedure and any extra arguments to be passed to it. Before string is invoked, three arguments are appended: 1) the current level 2) the current command line, and 3) a list containing the command after substitutions and split into words. The return status of the -precmd procedure is always ignored. -maxlevel number Specifies the maximum evaluation depth to watch Tcl commands. The default maximum level is 10000. watch deactivate watchName Deactivates the watch. The -precmd and -postcmd procedures will no longer be invoked. watch info watchName Returns the configuration information associated with the watch watchName. WatchName is the name of a watch. watch names ?state? Lists the names of the watches for a given state. State may be one of the following: active, idle, or ignore. If a state argument isn't specified, all watches are listed. KEYWORDS
debug, profile BLT
2.4 watch(n)
All times are GMT -4. The time now is 11:05 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy