Sponsored Content
Top Forums Shell Programming and Scripting redirect stdout echo command in condition A run in condition B Post 302570260 by jao_madn on Wednesday 2nd of November 2011 07:04:18 PM
Old 11-02-2011
Quote:
Originally Posted by Corona688
If it's present in both outputs, then it's taking the first branch in both outputs.

Can you explain it for me..If you dont mine..
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

redirect stderr and/or stdout to /dev/null from command line

Is it possible to redirect errors at the command line when you run the script such as bash scriptname & 2>/dev/null? (1 Reply)
Discussion started by: knc9233
1 Replies

2. UNIX for Advanced & Expert Users

STDOUT redirect to a FILE, when fuser command is used !!

Hi all, I have the following script: ------------------------------------------------- #SCRIPT TO CHECK WHO HAS ACCESSED THE LOG/FILE IN PAST 'N' MINUTES, AND MAIL ACCORDINGLY. MYPATH="/clocal/mqbrkrs/user/mqsiadm/sanjay/" MAIL_RECIPIENTS="vg517@dcx.com" Subject="File accessed in last... (6 Replies)
Discussion started by: varungupta
6 Replies

3. Shell Programming and Scripting

grep command with AND condition

I want to do a grep with AND condition. I have three files. file1.txt ======== UNIX ...... WINDOWS ........ ORACLE file2.txt ======== UNIX ....... WINDOWS ...and many such files in a directory (6 Replies)
Discussion started by: prasperl
6 Replies

4. Shell Programming and Scripting

multiple echo statements in if condition

Hi , I have a peculiar problem. i have an if block like this if ; then echo " todays date is " ${date} >> log_file echo " file count is " $ count >> log_file mv filename1 filename 2 else echo "no files available ">> log_file fi the echo statement "no files available " is not... (2 Replies)
Discussion started by: wizardofoz
2 Replies

5. HP-UX

Difference between [condition] and [[condition]] and ((condition)) when used with if condition

Executed the following if conditions .. and got different results . only (( )) gave correct o/p with all scenarios . Can anybody please let me know what is the difference between and ] and ((condition)) when used with if condition. And why each condition gave different result. 1.... (2 Replies)
Discussion started by: soumyabubun
2 Replies

6. UNIX for Dummies Questions & Answers

Diff command with a condition

Hi I have 2 files test1 & test2. Test1 contains : BSC AFCN Test2 contains: AFCN I than use the following command : diff file1 file2 which displays than displays : 2d1 < BSC Basically I want to confirm that except for "BSC", AFCN is the only word in each file.So when I do a... (6 Replies)
Discussion started by: Prega
6 Replies

7. Shell Programming and Scripting

How do I use paste command in while condition??

there are lot of files where in mostly all the file contains 2columnsAl,1 Ail,13 Al,3 Al,1 Al,3 Al,2 Al,3 Al,1 Al,1 Al,1 My requirement is i wanted only the second column of every file as a column ony in the base file... I used paste command... but it is not helping as I'm using while... (7 Replies)
Discussion started by: nikhil jain
7 Replies

8. Shell Programming and Scripting

Echo not displaying variable in If-Else condition

if then echo "Entry Valid : ${x_oug}" else echo "Entry Invalid : " 0 fi In the above code the 3rd line is not working... it does not print anything I tried following as well .. but no luck! echo "Entry Valid : ... (13 Replies)
Discussion started by: Chetanz
13 Replies

9. Shell Programming and Scripting

If condition return 0 even when it fails to satisfy te condition

HI My doubt may be basic one but I need to get it clarified.. When i use "if" condition that checks for many AND, OR logical conditions like if ]; then return 0 fi Even the if condition fails it returns as zero.. Any clue.. But if i add else condition like if ]; ... (2 Replies)
Discussion started by: Priya Amaresh
2 Replies
FLOCK(1)							   User Commands							  FLOCK(1)

NAME
flock - manage locks from shell scripts SYNOPSIS
flock [options] <file|directory> <command> [command args] flock [options] <file|directory> -c <command> flock [options] <file descriptor number> DESCRIPTION
This utility manages flock(2) locks from within shell scripts or the command line. The first and second forms wrap the lock around the executing a command, in a manner similar to su(1) or newgrp(1). It locks a specified file or directory, which is created (assuming appropriate permissions), if it does not already exist. By default, if the lock cannot be immediately acquired, flock waits until the lock is available. The third form uses open file by file descriptor number. See examples how that can be used. OPTIONS
-s, --shared Obtain a shared lock, sometimes called a read lock. -x, -e, --exclusive Obtain an exclusive lock, sometimes called a write lock. This is the default. -u, --unlock Drop a lock. This is usually not required, since a lock is automatically dropped when the file is closed. However, it may be required in special cases, for example if the enclosed command group may have forked a background process which should not be hold- ing the lock. -n, --nb, --nonblock Fail rather than wait if the lock cannot be immediately acquired. See the -E option for the exit code used. -w, --wait, --timeout seconds Fail if the lock cannot be acquired within seconds. Decimal fractional values are allowed. See the -E option for the exit code used. -o, --close Close the file descriptor on which the lock is held before executing command . This is useful if command spawns a child process which should not be holding the lock. -E, --conflict-exit-code number The exit code used when the -n option is in use, and the conflicting lock exists, or the -w option is in use, and the timeout is reached. The default value is 1. -c, --command command Pass a single command, without arguments, to the shell with -c. -h, --help Print a help message. -V, --version Show version number and exit. EXAMPLES
shell1> flock /tmp -c cat shell2> flock -w .007 /tmp -c echo; /bin/echo $? Set exclusive lock to directory /tmp and the second command will fail. shell1> flock -s /tmp -c cat shell2> flock -s -w .007 /tmp -c echo; /bin/echo $? Set shared lock to directory /tmp and the second command will not fail. Notice that attempting to get exclusive lock with second command would fail. shell> flock -x local-lock-file echo 'a b c' Grab the exclusive lock "local-lock-file" before running echo with 'a b c'. ( flock -n 9 || exit 1 # ... commands executed under lock ... ) 9>/var/lock/mylockfile The form is convenient inside shell scripts. The mode used to open the file doesn't matter to flock; using > or >> allows the lock- file to be created if it does not already exist, however, write permission is required. Using < requires that the file already exists but only read permission is required. [ "${FLOCKER}" != "$0" ] && exec env FLOCKER="$0" flock -en "$0" "$0" "$@" || : This is useful boilerplate code for shell scripts. Put it at the top of the shell script you want to lock and it'll automatically lock itself on the first run. If the env var $FLOCKER is not set to the shell script that is being run, then execute flock and grab an exclusive non-blocking lock (using the script itself as the lock file) before re-execing itself with the right arguments. It also sets the FLOCKER env var to the right value so it doesn't run again. EXIT STATUS
The command uses sysexits.h return values for everything else but an options -n or -w failures which return either the value given by the -E option, or 1 by default. AUTHOR
H. Peter Anvin <hpa@zytor.com> COPYRIGHT
Copyright (C) 2003-2006 H. Peter Anvin. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICU- LAR PURPOSE. SEE ALSO
flock(2) AVAILABILITY
The flock command is part of the util-linux package and is available from Linux Kernel Archive <ftp://ftp.kernel.org/pub/linux/utils/util- linux/>. util-linux September 2011 FLOCK(1)
All times are GMT -4. The time now is 04:51 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy