Sponsored Content
Full Discussion: Search for a word
Top Forums Shell Programming and Scripting Search for a word Post 302188227 by on9west on Wednesday 23rd of April 2008 02:54:15 AM
Old 04-23-2008
Search for a word

I would like to retrieve the word from the following file

filename abc.txt
------------------------------------------------------------------
Deadlock Id 28418: Process (Familyid 0, Spid 140) was waiting for a 'exclusive intent' lock on the 'request_copy_hist' table in database 4 b
ut process (Familyid 34, Spid 34) already held a 'exclusive table' lock on it.
Deadlock Id 28419: Process (Familyid 0, Spid 90) was waiting for a 'exclusive page' lock on page 57863937 of the 'testrslt' table in databas
e 4 but process (Familyid 65, Spid 65) already held a 'exclusive page' lock on it.
Deadlock Id 28419: Process (Familyid 0, Spid 65) was waiting for a 'shared page' lock on page 57891433 of the 'orders' table in database 4
but process (Familyid 90, Spid 90) already held a 'exclusive page' lock on it.
Deadlock Id 28420: Process (Familyid 0, Spid 90) was waiting for a 'exclusive page' lock on page 57863937 of the 'testrslt' table in databas
e 4 but process (Familyid 65, Spid 65) already held a 'exclusive page' lock on it.
Deadlock Id 28420: Process (Familyid 0, Spid 65) was waiting for a 'shared page' lock on page 57891433 of the 'upload' table in database 4
but process (Familyid 90, Spid 90) already held a 'exclusive page' lock on it.
Deadlock Id 28421: Process (Familyid 0, Spid 90) was waiting for a 'exclusive page' lock on page 57863937 of the 'testrslt' table in databas
e 4 but process (Familyid 65, Spid 65) already held a 'exclusive page' lock on it.
Deadlock Id 28421: Process (Familyid 0, Spid 65) was waiting for a 'shared page' lock on page 57891433 of the 'testrslt' table in database 4
but process (Familyid 90, Spid 90) already held a 'exclusive page' lock on it.
Deadlock Id 28422: Process (Familyid 0, Spid 65) was waiting for a 'shared page' lock on page 61234188 of the 'testrslt' table in database 4
but process (Familyid 90, Spid 90) already held a 'exclusive page' lock on it.
-------------------------------------------------------------------

my expected output:
--------------------
'request_copy_hist'
'testrslt'
'order'
'testrslt'
'upload'
'testrslt'
'testrslt'
'testrslt'

All the word is followed by "table in database", but in different column number. So I have no idea how to use awk or other method to do it.

Thank you very much
 

10 More Discussions You Might Find Interesting

1. Solaris

Search about word

Dear I want syntax to help me to find text or word inside files. i written the following syntax but i dont take what i need ( find ~ -name ahmad -print ) i need syntax to explain or launch more detail about all files and folder contain ( ahmd ) inside it. (3 Replies)
Discussion started by: abu_hassan
3 Replies

2. Shell Programming and Scripting

Word Search

Hi All, I have almost 1000+ files and I want to search specific pattern. Looking forwarded your input. Pls note that need to ignore words in between /* */ Search for: "insert into xyz" (Which procedure contain all 3). Expected output: procedure test1 function test2 procedure test3 ... (3 Replies)
Discussion started by: susau_79
3 Replies

3. Shell Programming and Scripting

Search the word to be deleted and delete lines above this word starting from P1 to P3

Hi, I have to search a word in a text file and then I have to delete lines above from the word searched . For eg suppose the file is like this: Records P1 10,23423432 ,77:1 ,234:2 P2 10,9089004 ,77:1 ,234:2 ,87:123 ,9898:2 P3 456456 P1 :123,456456546 P2 abc:324234 (2 Replies)
Discussion started by: vsachan
2 Replies

4. UNIX for Dummies Questions & Answers

Script to search for a particular word in files and print the word and path name

Hi, i am new to unix shell scripting and i need a script which would search for a particular word in all the files present in a directory. The output should have the word and file path name. For example: "word" "path name". Thanks for the reply in adv,:) (3 Replies)
Discussion started by: virtual_45
3 Replies

5. Shell Programming and Scripting

Search for the word and exporting 35 characters after that word using shell script?

I have a file input.txt which have loads of weird characters, html tags and useful materials. I want to display 35 characters after the word description excluding weird characters like $$#$#@$#@***$# and without html tags in the new file output.txt. Help me. Thanx in advance. My final goal is to... (11 Replies)
Discussion started by: sachit adhikari
11 Replies

6. Shell Programming and Scripting

Search for the word and exporting 35 characters after that word using shell script

I have a file input.txt which have loads of weird characters, html tags and useful materials. I want to display 35 characters after the word "description" excluding weird characters like $&lmp and without html tags in the new file output.txt. Help me. Thanx in advance. I have attached the input... (4 Replies)
Discussion started by: sachit adhikari
4 Replies

7. Shell Programming and Scripting

[Solved] Search for a word and print the next word

Hi, I am trying to search for a word and print the next word. For example: My text is "<TRANSFORMATION TYPE ="Lookup Procedure">" I am searching for "TYPE" and trying to print ="Lookup Procedure" I have written a code like following: echo $line | nawk... (4 Replies)
Discussion started by: sampoorna
4 Replies

8. Shell Programming and Scripting

Search for a specific word and print only the word from the input file

Hi, I have a sample file as shown below, I am looking for sed or any command which prints the complete word only from the input file. Ex: $ cat "sample.log" I am searching for a word which is present in this file We can do a pattern search using grep but I need to cut only the word which... (1 Reply)
Discussion started by: mohan_kumarcs
1 Replies

9. What is on Your Mind?

Updated Forum Search Index Min Word Length to 2 Chars and Added Quick Search Bar

Today I changed the forum mysql database to permit 2 letter searches: ft_min_word_len=2 I rebuilt the mysql search indexes as well. Then, I added a "quick search bar" at the top of each page. I have tested this and two letter searches are working; but it's not perfect,... (1 Reply)
Discussion started by: Neo
1 Replies

10. UNIX for Beginners Questions & Answers

How to search for a word in column header that fully matches the word not partially in awk?

I have a multicolumn text file with header in the first row like this The headers are stored in an array called . which contains I want to search for each elements of this array from that multicolumn text file. And I am using this awk approach for ii in ${hdr} do gawk -vcol="$ii" -F... (1 Reply)
Discussion started by: Atta
1 Replies
FLOCK(2)						     Linux Programmer's Manual							  FLOCK(2)

NAME
flock - apply or remove an advisory lock on an open file SYNOPSIS
#include <sys/file.h> int flock(int fd, int operation); DESCRIPTION
Apply or remove an advisory lock on the open file specified by fd. The argument operation is one of the following: LOCK_SH Place a shared lock. More than one process may hold a shared lock for a given file at a given time. LOCK_EX Place an exclusive lock. Only one process may hold an exclusive lock for a given file at a given time. LOCK_UN Remove an existing lock held by this process. A call to flock() may block if an incompatible lock is held by another process. To make a nonblocking request, include LOCK_NB (by ORing) with any of the above operations. A single file may not simultaneously have both shared and exclusive locks. Locks created by flock() are associated with an open file table entry. This means that duplicate file descriptors (created by, for exam- ple, fork(2) or dup(2)) refer to the same lock, and this lock may be modified or released using any of these descriptors. Furthermore, the lock is released either by an explicit LOCK_UN operation on any of these duplicate descriptors, or when all such descriptors have been closed. If a process uses open(2) (or similar) to obtain more than one descriptor for the same file, these descriptors are treated independently by flock(). An attempt to lock the file using one of these file descriptors may be denied by a lock that the calling process has already placed via another descriptor. A process may only hold one type of lock (shared or exclusive) on a file. Subsequent flock() calls on an already locked file will convert an existing lock to the new lock mode. Locks created by flock() are preserved across an execve(2). A shared or exclusive lock can be placed on a file regardless of the mode in which the file was opened. RETURN VALUE
On success, zero is returned. On error, -1 is returned, and errno is set appropriately. ERRORS
EBADF fd is not an open file descriptor. EINTR While waiting to acquire a lock, the call was interrupted by delivery of a signal caught by a handler; see signal(7). EINVAL operation is invalid. ENOLCK The kernel ran out of memory for allocating lock records. EWOULDBLOCK The file is locked and the LOCK_NB flag was selected. CONFORMING TO
4.4BSD (the flock() call first appeared in 4.2BSD). A version of flock(), possibly implemented in terms of fcntl(2), appears on most Unix systems. NOTES
flock() does not lock files over NFS. Use fcntl(2) instead: that does work over NFS, given a sufficiently recent version of Linux and a server which supports locking. Since kernel 2.0, flock() is implemented as a system call in its own right rather than being emulated in the GNU C library as a call to fcntl(2). This yields true BSD semantics: there is no interaction between the types of lock placed by flock() and fcntl(2), and flock() does not detect deadlock. flock() places advisory locks only; given suitable permissions on a file, a process is free to ignore the use of flock() and perform I/O on the file. flock() and fcntl(2) locks have different semantics with respect to forked processes and dup(2). On systems that implement flock() using fcntl(2), the semantics of flock() will be different from those described in this manual page. Converting a lock (shared to exclusive, or vice versa) is not guaranteed to be atomic: the existing lock is first removed, and then a new lock is established. Between these two steps, a pending lock request by another process may be granted, with the result that the conver- sion either blocks, or fails if LOCK_NB was specified. (This is the original BSD behavior, and occurs on many other implementations.) SEE ALSO
close(2), dup(2), execve(2), fcntl(2), fork(2), open(2), lockf(3) See also Documentation/filesystem/locks.txt in the kernel source (Documentation/locks.txt in older kernels). COLOPHON
This page is part of release 3.25 of the Linux man-pages project. A description of the project, and information about reporting bugs, can be found at http://www.kernel.org/doc/man-pages/. Linux 2009-07-25 FLOCK(2)
All times are GMT -4. The time now is 02:08 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy