I'm having trouble manipulating a string that contains single quotes (') in it. I'm writing a ksh script to parse in a few queries from a config file, such as this:
findbug \(\(Project 'in' "Deployment,HDRCI,LHS,LSS,WUCI" '&&' Status 'in' "N" '&&' New_on 'lessthan' "070107" \)\) '&&' \(Class... (9 Replies)
I need to count the number of files which have a search string, but counting the file only once
if search string is found.
eg: File1: Please note that there are 2 occurances of "aaa"
aaa
bbb
ccc
aaa
File2: Please note that there are 3 occurances of "aaa"
aaa
bbb
ccc... (1 Reply)
I'm not very familiar with the ssh command. When I tried to set a variable and then echo its value on a remote machine via ssh, I found a problem. For example,
$ ITSME=itsme
$ ssh xxx.xxxx.xxx.xxx "ITSME=itsyou; echo $ITSME"
itsme
$ ssh xxx.xxxx.xxx.xxx 'ITSME=itsyou; echo $ITSME'
itsyou
$... (3 Replies)
Hi All, I love this site, it helps newbie people like me and I appreciate everyone's help!
Here is my questions.
I am trying to concatenate a single quote into a character/string from a text file for each line (lets say ABC should look like 'ABC').
I tried to use awk print command to do... (1 Reply)
Hi,
I am trying out different scripts in PERL. I want to take a line/string as an input from the user and count the number of occurrances of all the alphabets (a..z) in the string. I tried doingit like this :
#! /opt/exp/bin/perl
print "Enter a string or line : ";
$string = <STDIN>;
chop... (5 Replies)
Unix superusers,
I am new to unix but would like to learn more about grep. I am very familiar with regular expressions as i have used them for searching text files in windows based text editors. Since I am not very familiar with Unix, I dont understand when one should use GREP with the... (2 Replies)
Hello. I'm trying to write a bash script that uses GNU screen and have hit a brick wall that has cost me many hours... (I'm sure it has something to do with quoting/globbing, which is why I post it here)
I can make a script that does the following just fine:
test.sh:
#!/bin/bash
# make... (2 Replies)
HI,
i have a file like this
t.txt
f1|_f2|_
f1|_f2|_
f1|_f2|_
as if col delimiter is |_ and row delimiter |_\n
trying to count number of records using awk
$ awk 'BEGIN{FS="|_" ; RS="~~\n"} {n++}END{print n} ' t.txt
7
wondering how can i count this to 3 ?
thx (9 Replies)
Hi,
Trying to change the prompt. I have the following code.
export PS1='
<${USER}@`hostname -s`>$ '
The hostname is not displayed
<abc@`hostname -s`>$ uname -a
AIX xyz 1 6 00F736154C00
<adcwl4h@`hostname -s`>$
If I use double quotes, then the hostname is printed properly but... (3 Replies)
Hi Froum.
I have tried in vain to find a solution for this problem - I'm trying to replace any double quotes within a quoted string with a single quote, leaving everything else as is.
I have the following data:
Before:
... (32 Replies)
Discussion started by: pchang
32 Replies
LEARN ABOUT SUSE
lockf
LOCKF(3) Linux Programmer's Manual LOCKF(3)NAME
lockf - apply, test or remove a POSIX lock on an open file
SYNOPSIS
#include <unistd.h>
int lockf(int fd, int cmd, off_t len);
Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
lockf(): _BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE >= 500
DESCRIPTION
Apply, test or remove a POSIX lock on a section of an open file. The file is specified by fd, a file descriptor open for writing, the
action by cmd, and the section consists of byte positions pos..pos+len-1 if len is positive, and pos-len..pos-1 if len is negative, where
pos is the current file position, and if len is zero, the section extends from the current file position to infinity, encompassing the
present and future end-of-file positions. In all cases, the section may extend past current end-of-file.
On Linux, lockf() is just an interface on top of fcntl(2) locking. Many other systems implement lockf() in this way, but note that
POSIX.1-2001 leaves the relationship between lockf() and fcntl(2) locks unspecified. A portable application should probably avoid mixing
calls to these interfaces.
Valid operations are given below:
F_LOCK Set an exclusive lock on the specified section of the file. If (part of) this section is already locked, the call blocks until the
previous lock is released. If this section overlaps an earlier locked section, both are merged. File locks are released as soon as
the process holding the locks closes some file descriptor for the file. A child process does not inherit these locks.
F_TLOCK
Same as F_LOCK but the call never blocks and returns an error instead if the file is already locked.
F_ULOCK
Unlock the indicated section of the file. This may cause a locked section to be split into two locked sections.
F_TEST Test the lock: return 0 if the specified section is unlocked or locked by this process; return -1, set errno to EAGAIN (EACCES on
some other systems), if another process holds a lock.
RETURN VALUE
On success, zero is returned. On error, -1 is returned, and errno is set appropriately.
ERRORS
EACCES or EAGAIN
The file is locked and F_TLOCK or F_TEST was specified, or the operation is prohibited because the file has been memory-mapped by
another process.
EBADF fd is not an open file descriptor.
EDEADLK
The command was T_LOCK and this lock operation would cause a deadlock.
EINVAL An invalid operation was specified in fd.
ENOLCK Too many segment locks open, lock table is full.
CONFORMING TO
SVr4, POSIX.1-2001.
SEE ALSO fcntl(2), flock(2)
There are also locks.txt and mandatory-locking.txt in the kernel source directory Documentation/filesystems. (On older kernels, these
files are directly under the Documentation/ directory, and mandatory-locking.txt is called mandatory.txt.)
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/.
GNU 2009-07-25 LOCKF(3)