08-04-2009
stampare righe precedenti ad un match in file
Salve a tutti...volevo chiedere a voi,che sicuramente ne sapete piu di me,come posso ottenere la seguente soluzione:
ho un file del tipo:
CIAO COME STAI
PERCHE COME STAI
CIAO COME VA
ALLO CHE FACCIAMO
.................
io vorre che nel caso in cui in una riga è presenta la parola "CHE" allora stampo a video le tre righe precedenti alla parola ottenendo quindi:
CIAO COME STAI
PERCHE COME STAI
CIAO COME VA
Come shell uso la KORN SHELL..vi ringrazio in anticipo per l'aiuto...
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi All,
I have a below file:
==================
02:53 pravin-root
02:53 pravin-root
03:05 pravin-root
02:55 pravin1-root
02:59 pravin1-root
==================
How do I find the first and last value of column 1. For example, how do I find 02:53 is the first time stamp and 03:05 is... (3 Replies)
Discussion started by: praving5
3 Replies
2. Shell Programming and Scripting
Hi,
I have two files. 1st file has 1 column (huge file containing ~19200000 lines) and 2nd file has 2 columns (small file containing ~6000 lines).
#################################
huge_file.txt
a
a
ab
b
##################################
small_file.txt
a 1.5
b 2.5
ab ... (4 Replies)
Discussion started by: AshwaniSharma09
4 Replies
3. Shell Programming and Scripting
salve a tutti, sono nuovo di questo forum e sono nuovo anche come shell scripter diciamo.
il mio problema è quello di avere dei files html in una directory e da questi vorrei estrarre un dato che si trova tra due righe differenti
Ecco la mia situazione
<td align="default">ossidabilità (mg/l):
... (1 Reply)
Discussion started by: sbobotex
1 Replies
4. UNIX for Dummies Questions & Answers
I have the below 2 files:
1) Third field from file1.txt should be compared to the first field of lookup.txt.
2) If match found then third field, file1.txt should be substituted with the second field from lookup.txt.
3)Else just print the line from file1.txt.
File1.txt:... (4 Replies)
Discussion started by: venalla_shine
4 Replies
5. Shell Programming and Scripting
Hi Friends,
I'm a great fan of this forum... it has helped me tone my skills in shell scripting. I have a challenge here, which I'm sure you guys would help me in achieving...
File A has a list of job ids and I need to compare this with the File B (*.log) and File C (extend *.log) and copy... (6 Replies)
Discussion started by: asnandhakumar
6 Replies
6. Shell Programming and Scripting
not getting anywhere with this
an xml file contains multiple clients set up with same tags, different values.
I need to parse the file for client foo, and change the value of tag "64bit" from false to true.
cat clients.xml
<Client type"FIX">
<ClientName>foo</ClientName>... (3 Replies)
Discussion started by: jack.bauer
3 Replies
7. Shell Programming and Scripting
The below bash connects to a site, downloads a file, searches that file based of user input - could be multiple (all that seems to work). What I am not able to figure out is how to display on the screen match found or no match found" and write a file to a directory (C:\Users\cmccabe\Desktop\wget)... (4 Replies)
Discussion started by: cmccabe
4 Replies
8. Shell Programming and Scripting
I have a specific set (all ending with .bam) of downloaded files in a directory /home/cmccabe/Desktop/NGS/API/2-15-2016. What I am trying to do is use a match to $2 in name to rename the downloaded files. To make things a more involved the date of the folder is unique and in the header of name... (1 Reply)
Discussion started by: cmccabe
1 Replies
9. Shell Programming and Scripting
I am trying to create a cronjob that will run on startup that will look at a list.txt file to see if there is a later version of a database using database.txt as the source. The matching lines are written to output.
$1 in database.txt will be in list.txt as a partial match. $2 of database.txt... (2 Replies)
Discussion started by: cmccabe
2 Replies
10. Shell Programming and Scripting
I need to find two matches in the output from ps. I am searching with ps -ef |grep mysql for:
my.cnf
/bin/sh /usr/bin/mysqld_safe --defaults-file=/data/mysql/master/agis_core/etc/my.cnf
after this match I want to search back and match the hostname which is x number of lines back, above the... (2 Replies)
Discussion started by: bash_in_my_head
2 Replies
LEARN ABOUT OPENDARWIN
xmlcatalog
XMLCATALOG(1) xmlcatalog Manual XMLCATALOG(1)
NAME
xmlcatalog - Command line tool to parse and manipulate XML or SGML catalog files.
SYNOPSIS
xmlcatalog [--shell | --create | --add type orig replace
| --del values | --noout | --verbose] [catalogfile]
[entities]
INTRODUCTION
xmlcatalog is a command line application allowing users to monitor and manipulate XML and SGML catalogs. It is included in libxml2.
Its functions can be invoked from a single command from the command line, or it can perform multiple functions in interactive mode. It can
operate on both XML and SGML files.
COMMAND LINE OPTIONS
--shell filename
Run a shell allowing interactive queries on catalog file filename.
--create filename
Create a new XML catalog. Outputs to stdout, ignoring filename unless --noout is used, in which case it creates a new catalog file
filename.
--add 'type' 'orig' 'replace' filename
Add an entry to catalog file filename. type indicates the type of entry. Possible types are 'public', 'system', 'rewriteSystem',
'delegatePublic', 'delegateSystem'amd 'rewriteURI'. 'orig' is the original reference to be replaced, and 'replace' is the URI of the
replacement entity to be used. The --add option will not overwrite filename, outputing to stdout, unless --noout is used. The --add
will always take three parameters even if some of the XML catalog constructs will have only a single argument.
If the --add option is used following the --sgml option, only a single argument, a filename, is used. This is used to add the name
of a catalog file to an SGML supercatalog, a file that contains references to other included SGML catalog files.
--del 'values' filename
Remove entries from the catalog file filename matching 'values'. The --del option will not overwrite filename, outputing to stdout,
unless --noout is used.
--noout
Save output to the named file rather than outputing to stdout.
--sgml Uses SGML Super catalogs for --add and --del options
-v or --verbose
output debugging information.
SHELL COMMANDS
Invoking xmlcatalog with the --shell filename option opens a command line shell allowing interactive access to the catalog file identified
by filename. Invoking the shell provides a command line prompt after which commands can be entered.
public 'PublicID'
Execute a public identifier lookup of the catalog entry for 'PublicID'. The corresponding entry will be output to the command line.
system 'SystemID'
Execute a public identifier lookup of the catalog entry for 'SystemID'. The corresponding entry will be output to the command line.
add 'type' 'orig' 'replace'
Add an entry to the catalog file. type indicates the type of entry. Possible types are 'public', 'system', 'rewriteSystem', 'dele-
gatePublic' and 'delegateSystem'. 'orig' is the original reference to be replaced, and 'replace' is the URI of the replacement
entity to be used.
del 'values'
Remove the catalog entry corresponding to 'values'.
dump Print the current catalog.
debug Print debugging statements showing the steps xmlcatalog is executing.
quiet Stop printing debugging statements.
exit Quit the shell.
RETURN VALUES
xmlcatalog's return codes provide information that can be used when calling it from scripts.
0: normal
1: Failed to remove an entry from the catalog
2: Failed to save to the catalog, check file permissions
3: Failed to add an entry to the catalog
4: Failed to lookup and entry in the catalog
REFERENCES
libxml web page: http://www.xmlsoft.org/
libxml catalog support web page:: http://www.xmlsoft.org/catalog.html
James Clark's SGML catalog page:: http://www.jclark.com/sp/catalog.htm
OASIS XML catalog specification: : http://www.oasis-open.org/committees/entity/spec.html
AUTHOR
John Fleck.
XMLCATALOG(1)