Sponsored Content
Full Discussion: complexing dd
Top Forums Shell Programming and Scripting complexing dd Post 302364915 by steadyonabix on Saturday 24th of October 2009 02:54:49 PM
Old 10-24-2009
You could do this with multiple dd statements.

To scale things down, this is an input file with five bytes per line: -

Code:
poweredge:/home/brad/forum/skipdd>cat ddout
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020

To read the third block of five bytes: -

Code:
poweredge:/home/brad/forum/skipdd>dd if=ddout bs=5 skip=2 count=1       
1003
1+0 records in
1+0 records out

To read the 6th block: -

Code:
poweredge:/home/brad/forum/skipdd>dd if=ddout bs=5 skip=5 count=1
1006
1+0 records in
1+0 records out

 
FLOCK(1)						    BSD General Commands Manual 						  FLOCK(1)

NAME
flock -- Provide locking API for shell scripts SYNOPSIS
flock [-dnosvx] [-w timeout] lockfile|lockdir [-c command] | [command ...] flock [-dnsuvx] [-w timeout] lockfd DESCRIPTION
The flock utility provides flock(2) access to the command line or scripts. The first form locks a file or directory while the command pro- vided is executed. If the file or directory does not exist, then a file is created. The second form can use an arbitrary file descriptor that is provided from a shell script for example: ( flock -s 100 # commands to be executed under the lock ) 100> /path/to/lockfile The following options are available: -c command Pass a command to a the shell. -d, --debug Provide debugging output. -n, --nb, --nonblock Don't block and fail immediately if the lock could not be obtained. -o, --close Close the file before executing the command. This is useful if the child forks and should not be holding the lock. -s, --shared Obtain a shared lock. -u, --unlock Unlock an existing lock. This is available only for a file descriptor. -v, --verbose On error print an explanation of the failure. -w, --wait, --timeout seconds Fail if the lock could not be obtained after seconds. -x, --exclusive Obtain an exclusive lock. EXIT STATUS
The flock utility exits 0 on success, and >0 if an error occurs. SEE ALSO
shlock(1), flock(2) HISTORY
An flock utility appeared in NetBSD 6.1. BSD
November 2, 2012 BSD
All times are GMT -4. The time now is 04:23 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy