04-03-2008
Hi.
One could also break the pipeline into pieces, using scratch files to communicate, so that one could test the exit status of each part.
A more complex solution involves using another process for each piece, as explained in
``Answers to Unix'' Column: No. 003 -- quite inventive I think.
Some shells may offer
pipefail --
bash and
ksh, for example:
Quote:
If pipefail is enabled, the
pipeline's return status is the value of the last (rightmost) command
to exit with a non-zero status, or zero if all commands exit success-
fully.
-- excerpt from man bash
... cheers, drl
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi Guys.
I am a complete shell scripting newbie with some syntax and commands understanding. I'm more of a win admin. With that said: I need to write a shell script to monitor a directory '/Mon_Dir' for new occurrences of files with .xx extension. Once a new file is detected in the directory, a... (4 Replies)
Discussion started by: krkan
4 Replies
2. Shell Programming and Scripting
The purpose of those comands are to find the newest file in a directory acvrdind to system date, and it has to be recursively found in each directory.
The problem is that i want to list in a long format every found file, but the commands i use produce unexpected results ,so the output lists in a... (5 Replies)
Discussion started by: alexcol
5 Replies
3. Shell Programming and Scripting
I want the output of the find command to be printed and also the total files found by it. Can someone help in this.
Obviously $ find . -type f | wc -l will not output the files found but only the count. I want both. There can be millions and trillions of files so dont want the output of find... (3 Replies)
Discussion started by: amicon007
3 Replies
4. Shell Programming and Scripting
Hi I am trying to write a script which will loop through all files that end in ".txt" and ask user if they want to delete the file or not
#this print out all files
dir=/root/etc/
find $dir -name "*.txt"
output:
1.txt
2.txt
etc
but what i really want is
1.txt delete(Y/N):
2.txt ... (11 Replies)
Discussion started by: Calypso
11 Replies
5. Shell Programming and Scripting
hi ,
I have certain files at the same path with differeent extensions like .dat , .txt etc ...........i need to rename them with extension .found at the same path with the help of loop....
also the files names will be like this ;
abc_2010_c1.dat
abc_2010_c2.dat
xyz_2010_c1.txt (2 Replies)
Discussion started by: amitpta
2 Replies
6. Shell Programming and Scripting
I believe what is happening is rm is executing in the script on every directory and on failure of the first it stops although returns status 0.
find $HOME -name /directory/filename | xargs -l rm
This is the code I use but file remains. I am using sun solaris system which has way limited... (4 Replies)
Discussion started by: Ebodee
4 Replies
7. UNIX for Dummies Questions & Answers
i have executed the following command in terminal
find /Users/vasu -name "*.txt" -print
and i am getting the result
/Users/vasu/file1.txt
/Users/vasu/file2.txt
/Users/vasu/file3.txtbut while i was trying to execute the same in the script it is not working,I tried with below logic in... (2 Replies)
Discussion started by: vmachava
2 Replies
8. Shell Programming and Scripting
can any1 please tell me what is problem with following code:
i=1;
cat test| while read CMD;
do
Var$i=$CMD; or Var$i=$(echo $CMD) ;
let i++
doneI keep getting error :
line 4: Var1=sometext: command not found (2 Replies)
Discussion started by: kashif.live
2 Replies
9. Shell Programming and Scripting
i=0
numberofproducts=${#urls} #gets number of entries in array called "urls"
numberofproductsminusone=`expr $numberofproducts - 1` #-subtract by one
while
do
wget ${urls}
i=$(( $i + 1 ))
sleep 10
done
I'm getting an error
./scrape: line 22: [0: command not found
that... (3 Replies)
Discussion started by: phpchick
3 Replies
10. Shell Programming and Scripting
Hello Forum,
We have two bootstraps of Chef in our environment which are identified by colour:
/var/chef/cache/cookbooks/bootstrap_cookbooks_version_green
and
/var/chef/cache/cookbooks/bootstrap_cookbooks_version_red
I'm attempting to identify which version is installed based on the name... (11 Replies)
Discussion started by: greavette
11 Replies
LOSETUP(8) MAINTENANCE COMMANDS LOSETUP(8)
NAME
losetup - set up and control loop devices
SYNOPSIS
Get info:
losetup loopdev
losetup -a
losetup -j file [-o offset]
Delete loop:
losetup -d loopdev...
Print name of first unused loop device:
losetup -f
Setup loop device:
losetup [{-e|-E} encryption] [-o offset] [--sizelimit limit]
[-p pfd] [-r] {-f[--show]|loopdev} file
Resize loop device:
losetup -c loopdev
DESCRIPTION
losetup is used to associate loop devices with regular files or block devices, to detach loop devices and to query the status of a loop
device. If only the loopdev argument is given, the status of the corresponding loop device is shown.
Encryption
It is possible to specify transfer functions (for encryption/decryption or other purposes) using one of the -E and -e options. There are
two mechanisms to specify the desired encryption: by number and by name. If an encryption is specified by number then one has to make sure
that the Linux kernel knows about the encryption with that number, probably by patching the kernel. Standard numbers that are always
present are 0 (no encryption) and 1 (XOR encryption). When the cryptoloop module is loaded (or compiled in), it uses number 18. This
cryptoloop module will take the name of an arbitrary encryption type and find the module that knows how to perform that encryption.
OPTIONS
-a, --all
show status of all loop devices
-c, --set-capacity loopdev
force loop driver to reread size of the file associated with the specified loop device
-d, --detach loopdev...
detach the file or device associated with the specified loop device(s)
-e, -E, --encryption encryption_type
enable data encryption with specified name or number
-f, --find
find the first unused loop device. If a file argument is present, use this device. Otherwise, print its name
-h, --help
print help
-H, --phash hash_type
Specify the password hash function. Valid values are: sha512(default), sha256, sha384, rmd160, none.
-j, --associated file
show status of all loop devices associated with given file
-k, --keybits num
set the number of bits to use in key to num.
-o, --offset offset
the data start is moved offset bytes into the specified file or device
--sizelimit limit
the data end is set to no more than sizelimit bytes after the data start
-p, --pass-fd num
read the passphrase from file descriptor with number num instead of from the terminal
-r, --read-only
setup read-only loop device
--show print device name if the -f option and a file argument are present.
The short form of this option (-s) is deprecated. This short form could be in collision with Loop-AES implementation where the same
option is used for --sizelimit.
-v, --verbose
verbose mode
RETURN VALUE
losetup returns 0 on success, nonzero on failure. When losetup displays the status of a loop device, it returns 1 if the device is not con-
figured and 2 if an error occurred which prevented losetup from determining the status of the device.
FILES
/dev/loop0, /dev/loop1, ... loop devices (major=7)
EXAMPLE
If you are using the loadable module you must have the module loaded first with the command
# modprobe loop
Maybe also encryption modules are needed.
# modprobe des # modprobe cryptoloop
The following commands can be used as an example of using the loop device.
# dd if=/dev/zero of=/file bs=1k count=100
# losetup -e des /dev/loop0 /file
Password:
Init (up to 16 hex digits):
# mkfs -t ext2 /dev/loop0 100
# mount -t ext2 /dev/loop0 /mnt
...
# umount /dev/loop0
# losetup -d /dev/loop0
If you are using the loadable module you may remove the module with the command
# rmmod loop
RESTRICTION
DES encryption is painfully slow. On the other hand, XOR is terribly weak. Both are insecure nowadays. Some ciphers may require a licence
for you to be allowed to use them.
Cryptoloop is deprecated in favor of dm-crypt. For more details see cryptsetup(8).
AVAILABILITY
The losetup command is part of the util-linux-ng package and is available from ftp://ftp.kernel.org/pub/linux/utils/util-linux-ng/.
Linux 2003-07-01 LOSETUP(8)