Sponsored Content
Top Forums Shell Programming and Scripting Grep a string and write a value to next line of found string Post 302547685 by Franklin52 on Tuesday 16th of August 2011 10:30:35 AM
Old 08-16-2011
Quote:
Originally Posted by angel12345
Hi franklin,
thanks for the reply.
can u pls explain this for my future reference.
Sure:
Code:
awk -F= '				# field separator is "="
/wf_xxxxxx/{				# when the regexp is matched
  print; getline; $(NF+1)=x;		# print the line, get the next line and add x as last field
  print; getline; $(NF+1)=y}		# print the line, get the next line and add y as last field
1' x="value1" y="value2" OFS="=" file > newfile

Quote:
also i want to write the values of x and y into $$a and $$b
Post an example of the input file and the desired output.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to replace all string instances found by find+grep

Hello all Im performing find + grep operation that looks like this : find . -name "*.dsp" | xargs grep -on Project.lib | grep -v ':0' and I like to add to this one liner the possibility to replace the string " Project.lib" that found ( more then once in file ) with "Example.lib" how can I do... (0 Replies)
Discussion started by: umen
0 Replies

2. Shell Programming and Scripting

grep to show date/time of file the string was found in.

I've seen several examples of grep showing the filename the string was found in, but what I really need is grep to show the file details in long format (like ls -l would). scenario is: grep mobile_number todays_files This will show me the string I'm after & which files they turn up in, but... (2 Replies)
Discussion started by: woodstock
2 Replies

3. Shell Programming and Scripting

Grep a string and print a string from the line below it

I know how to grep, copy and paste a string from a line. Now, what i want to do is to find a string and print a string from the line below it. To demonstrate: Name 1: ABC Age: 3 Sex: Male Name 2: DEF Age: 4 Sex: Male Output: 3 Male I know how to get "3". My biggest problem is to... (4 Replies)
Discussion started by: kingpeejay
4 Replies

4. Shell Programming and Scripting

grep on string and printing line after until another string has been found

Hello Everyone, I just started scripting this week. I have no background in programming or scripting. I'm working on a script to grep for a variable in a log file Heres what the log file looks like. The x's are all random clutter xxxxxxxxxxxxxxxxxxxxx START: xxxxxxxxxxxx... (7 Replies)
Discussion started by: rxc23816
7 Replies

5. Shell Programming and Scripting

Grep a string from input file and delete next three lines including the line contains string in xml

Hi, 1_strings file contains $ cat 1_strings /home/$USER/Src /home/Valid /home/Review$ cat myxml <projected value="some string" path="/home/$USER/Src"> <input 1/> <estimate value/> <somestring/> </projected> <few more lines > <projected value="some string" path="/home/$USER/check">... (4 Replies)
Discussion started by: greet_sed
4 Replies

6. UNIX for Dummies Questions & Answers

Append a string on the next line after a pattern string is found

Right now, my code is: s/Secondary Ins./Secondary Ins.\ 1/g It's adding a 1 as soon as it finds Secondary Ins. Primary Ins.: MEDICARE B DMERC Secondary Ins. 1: CONTINENTAL LIFE INS What I really want to achieve is having a 1 added on the next line that contain "Secondary Ins." It... (4 Replies)
Discussion started by: newbeee
4 Replies

7. Shell Programming and Scripting

grep exact string from files and write to filename when string present in file

I am attempting to grep an exact string from a series of files within a directory and append that output to the filename when it is present in the file. I've been after this all day with no luck. Thanks for your help in advance :wall:. (4 Replies)
Discussion started by: JC_1
4 Replies

8. Shell Programming and Scripting

Grep and replace with found string

Hi, I need to find all rows in 1st col of one file in another file (first occurrence) and replace the 1st col of first file with the grep result (the entire line). For example search AA from file 1 in file 2 and replace in file 1 by entire line found. File1 AA BB CC DD BB AA CC DDFile2 ... (2 Replies)
Discussion started by: ritakadm
2 Replies

9. Shell Programming and Scripting

Insert line based on found string

Hi All I'm trying to insert a new line at the before each comment line in a file. Comment lines start with '#-----' there are other comments with in lines but I don't want a new line there. Example file: blah blah #do not insert here #this is a comment blah #some more #another comment... (10 Replies)
Discussion started by: Mudshark
10 Replies

10. Shell Programming and Scripting

How to uppercase matching line when string found?

Hello, Could you please help me how to search the string in a file, and when found; change the existing line to uppercase in command line? I tried: ?whichcommand? -A "EXT" fileA | awk '{print tolower($0)}' | tee fileB tr command simply converts entire file to uppercase but this is not what... (4 Replies)
Discussion started by: baris35
4 Replies
PEGASUS-ANALYZER(1)													       PEGASUS-ANALYZER(1)

NAME
pegasus-analyzer - debugs a workflow. SYNOPSIS
pegasus-analyzer [--help|-h] [--quiet|-q] [--strict|-s] [--monitord|-m|-t] [--verbose|-v] [--output-dir|-o output_dir] [--dag dag_filename] [--dir|-d|-i input_dir] [--print|-p print_options] [--debug-job job] [--debug-dir debug_dir] [--type workflow_type] [--conf|-c property_file] [--files] [--top-dir dir_name] [workflow_directory] DESCRIPTION
pegasus-analyzer is a command-line utility for parsing the jobstate.log file and reporting successful and failed jobs. When executed without any options, it will query the SQLite or MySQL database and retrieve failed job information for the particular workflow. When invoked with the --files option, it will retrieve information from several log files, isolating jobs that did not complete successfully, and printing their stdout and stderr so that users can get detailed information about their workflow runs. OPTIONS
-h, --help Prints a usage summary with all the available command-line options. -q, --quiet Only print the the output and error filenames instead of their contents. -s, --strict Get jobs' output and error filenames from the job's submit file. -m, -t, --monitord Invoke pegasus-monitord before analyzing the jobstate.log file. Although pegasus-analyzer can be executed during the workflow execution as well as after the workflow has already completed execution, pegasus-monitord" is always invoked with the --replay option. Since multiple instances of pegasus-monitord" should not be executed simultaneously in the same workflow directory, the user should ensure that no other instances of pegasus-monitord are running. If the run_directory is writable, pegasus-analyzer will create a jobstate.log file there, rotating an older log, if it is found. If the run_directory is not writable (e.g. when the user debugging the workflow is not the same user that ran the workflow), pegasus-analyzer will exit and ask the user to provide the --output-dir option, in order to provide an alternative location for pegasus-monitord log files. -v, --verbose Sets the log level for pegasus-analyzer. If omitted, the default level will be set to WARNING. When this option is given, the log level is changed to INFO. If this option is repeated, the log level will be changed to DEBUG. -o output_dir, --output-dir output_dir This option provides an alternative location for all monitoring log files for a particular workflow. It is mainly used when an user does not have write privileges to a workflow directory and needs to generate the log files needed by pegasus-analyzer. If this option is used in conjunction with the --monitord option, it will invoke pegasus-monitord using output_dir to store all output files. Because workflows can have sub-workflows, pegasus-monitord will create its files prepending the workflow wf_uuid to each filename. This way, multiple workflow files can be stored in the same directory. pegasus-analyzer has built-in logic to find the specific jobstate.log file by looking at the workflow braindump.txt file first and figuring out the corresponding wf_uuid. If output_dir does not exist, it will be created. --dag 'dag_filename In this option, dag_filename specifies the path to the DAG file to use. pegasus-analyzer will get the directory information from the dag_filename. This option overrides the --dir option below. -d input_dir, -i input_dir, --dir input_dir Makes pegasus-analyzer look for the jobstate.log file in the input_dir directory. If this option is omitted, pegasus-analyzer will look in the current directory. -p print_options, --print print_options Tells pegasus-analyzer what extra information it should print for failed jobs. print_options is a comma-delimited list of options, that include pre, invocation, and/or all, which activates all printing options. With the pre option, pegasus-analyzer will print the pre-script information for failed jobs. For the invocation option, pegasus-analyzer will print the invocation command, so users can manually run the failed job. --debug-job job When given this option, pegasus-analyzer turns on its debug_mode, when it can be used to debug a particular job. In this mode, pegasus-analyzer will create a shell script in the debug_dir (see below, for specifying it) and copy all necessary files to this local directory and then execute the job locally. --debug-dir debug_dir When in debug_mode, pegasus-analyzer will create a temporary debug directory. Users can give this option in order to specify a particular debug_dir directory to be used instead. --type workflow_type In this options, users specify what workflow_type they want to debug. At this moment, the only workflow_type available is condor and it is the default value if this option is not specified. -c property_file, --conf property_file This option is used to specify an alternative property file, which may contain the path to the database to be used by pegasus-analyzer. If this option is not specified, the config file specified in the braindump.txt file will take precedence. --files This option allows users to run pegasus-analyzer using the files in the workflow directory instead of the database as the source of information. pegasus-analyzer will output the same information, this option only changes where the data comes from. --top-dir dir_name This option enables pegasus-analyzer to show information about sub-workflows when using the database mode. When debugging a top-level workflow with failures in sub-workflows, the analyzer will automatically print the command users should use to debug a failed sub-workflow. This allows the analyzer to find the database it needs to access. ENVIRONMENT VARIABLES
pegasus-analyzer does not require that any environmental variables be set. It locates its required Python modules based on its own location, and therefore should not be moved outside of Pegasus' bin directory. EXAMPLE
The simplest way to use pegasus-analyzer is to go to the run_directory and invoke the analyzer: $ pegasus-analyzer . which will cause pegasus-analyzer to print information about the workflow in the current directory. pegasus-analyzer output contains a summary, followed by detailed information about each job that either failed, or is in an unknown state. Here is the summary section of the output: **************************Summary*************************** Total jobs : 75 (100.00%) # jobs succeeded : 41 (54.67%) # jobs failed : 0 (0.00%) # jobs unsubmitted : 33 (44.00%) # jobs unknown : 1 (1.33%) jobs_succeeded are jobs that have completed successfully. jobs_failed are jobs that have finished, but that did not complete successfully. jobs_unsubmitted are jobs that are listed in the dag_file, but no information about them was found in the jobstate.log file. Finally, jobs_unknown are jobs that have started, but have not reached completion. After the summary section, pegasus-analyzer will display information about each job in the job_failed and job_unknown categories. ******************Failed jobs' details********************** =======================findrange_j3========================= last state: POST_SCRIPT_FAILURE site: local submit file: /home/user/diamond-submit/findrange_j3.sub output file: /home/user/diamond-submit/findrange_j3.out.000 error file: /home/user/diamond-submit/findrange_j3.err.000 --------------------Task #1 - Summary----------------------- site : local hostname : server-machine.domain.com executable : (null) arguments : -a findrange -T 60 -i f.b2 -o f.c2 error : 2 working dir : In the example above, the findrange_j3 job has failed, and the analyzer displays information about the job, showing that the job finished with a POST_SCRIPT_FAILURE, and lists the submit, output and error files for this job. Whenever pegasus-analyzer detects that the output file contains a kickstart record, it will display the breakdown containing each task in the job (in this case we only have one task). Because pegasus-analyzer was not invoked with the --quiet flag, it will also display the contents of the output and error files (or the stdout and stderr sections of the kickstart record), which in this case are both empty. In the case of SUBDAG and subdax jobs, pegasus-analyzer will indicate it, and show the command needed for the user to debug that sub-workflow. For example: =================subdax_black_ID000009===================== last state: JOB_FAILURE site: local submit file: /home/user/run1/subdax_black_ID000009.sub output file: /home/user/run1/subdax_black_ID000009.out error file: /home/user/run1/subdax_black_ID000009.err This job contains sub workflows! Please run the command below for more information: pegasus-analyzer -d /home/user/run1/blackdiamond_ID000009.000 -----------------subdax_black_ID000009.out----------------- Executing condor dagman ... -----------------subdax_black_ID000009.err----------------- tells the user the subdax_black_ID000009 sub-workflow failed, and that it can be debugged by using the indicated pegasus-analyzer command. SEE ALSO
pegasus-status(1), pegasus-monitord(1), pegasus-statistics(1). AUTHORS
Fabio Silva <fabio at isi dot edu> Karan Vahi <vahi at isi dot edu> Pegasus Team http://pegasus.isi.edu 05/24/2012 PEGASUS-ANALYZER(1)
All times are GMT -4. The time now is 11:08 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy