Sponsored Content
Full Discussion: BASH Corrupts Files?
Top Forums Shell Programming and Scripting BASH Corrupts Files? Post 302942722 by Don Cragun on Thursday 30th of April 2015 07:16:32 PM
Old 04-30-2015
That isn't a bash ism. The set -C (aka set -o noclobber) option and its interaction with the:
Code:
fd> file

and:
Code:
fd>| file

redirection operators is required in all POSIX conforming shells...
Code:
#!/bin/bash
options=$(set +o)	# Save current shell options
set -C			# Set noclobber option (synonym for "set -o noclobber"
if > xyzzy		# Fail if file already exists
then	echo '> xyzzy succeeded'
else	echo '> xyzzy failed'
fi
if > xyzzy		# Fail if file already exists
then	echo '2nd > xyzzy succeeded'
else	echo '2nd > xyzzy failed'
fi
if >| xyzzy		# Succeed even if file already exists (as long as you
			# have write permission)
then	echo '>| xyzzy succeeded'
else	echo '>| xyzzy failed'
fi
$options		# Reset original shell options
rm -f xyzzy		# Remove test file

produces output similar to:
Code:
> xyzzy succeeded
tester: line 8: xyzzy: cannot overwrite existing file
2nd > xyzzy failed
>| xyzzy succeeded

I said similar to because the format of the diagnostic message can vary slightly from shell to shell and system to system.
These 2 Users Gave Thanks to Don Cragun For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

.bash files

i have been interacting a little with the forum in the last couple of days and to tell the truth I have learnt quite a bit from some of the posts that I have read accessed or posted.. from some of the books that I have read I have a pretty good idea about shells, profile files, .bashrc, etc, etc... (4 Replies)
Discussion started by: moxxx68
4 Replies

2. Shell Programming and Scripting

bash script working for small size files but not for big size files.

Hi, I have one file stat. Stat file contents are as follows: for example. H50768020040913,00260100,507680,13,0000000643,0000000643,00000,0000 H50769520040808,00260100,507695,13,0000000000,0000000000,00000,0000 H50770620040611,00260100,507706,13,0000000000,0000000000,00000,0000 Now i... (1 Reply)
Discussion started by: davidpreml
1 Replies

3. UNIX for Advanced & Expert Users

Secure FTP corrupts file

Sun Microsystems Inc. SunOS 5.9 I am hoping someone has come across this before. I have a script that transfers several gz files via Secure FTP across to an SFTP server on an NT machine. The transfers show as successful: pack12_200812160337.tar.gz | 768kB | 768kB/s | ETA: 00:00:01 | 37%... (5 Replies)
Discussion started by: ronnie_uk
5 Replies

4. Shell Programming and Scripting

[bash] Parse files

Hi I've 2 folder A and B, they have files with the same name but different content. I mean A contain---------> aa.txt, bb.txt, cc.txt B contain---------> aa.txt, bb.txt, cc.txt but aa.txt in A has different content from aa.txt in B. I'd like to parse the homonyms files in... (7 Replies)
Discussion started by: Dedalus
7 Replies

5. Shell Programming and Scripting

Using bash to separate files files based on parts of a filename

Hey guys, Sorry for the basic question but I have a lot of files that I want to separate into groups based on filenames which I can then cat together. Eg I have: (a_b_c.txt) WB34_2_SLA8.txt WB34_1_SLA8.txt WB34_1_DB10.txt WB34_2_DB10.txt WB34_1_SLA8.txt WB34_2_SLA8.txt 77_1_SLA8.txt... (1 Reply)
Discussion started by: Breentax
1 Replies

6. Shell Programming and Scripting

LFTP corrupts special characters

Hi, I am trying to use lftp to mirror two directories: one on my windows pc and one on a zOS system. One file within the local directory has special characters for different languages, e.g. pou¶ít (czech). When I run lftp, the characters are incorrect. I am transferring in ASCII mode, and the... (5 Replies)
Discussion started by: adam.wis
5 Replies

7. UNIX for Dummies Questions & Answers

Bash script to sort files

I've got a disorganized list of items and quantities for each. I've been using a combination of grep and sort to find out how much to buy of each item. I'm tired of having to constantly using these commands so I've been trying to write a shell script to make it easier, but I can't figure out how... (3 Replies)
Discussion started by: PTcharger
3 Replies

8. Shell Programming and Scripting

Bash: join 2 files

Hello ! I want to join 2 files. They look like this: KE340296.1 1 0/0:11 KE340296.1 2 0/0:12 KE340296.1 6 0/1:13 KE340297.1 1 0/1:14 KE340297.1 3 0/1:15 KE340297.1 4 0/1:16 and KE340296.1 1 0/0:21 KE340296.1 2 0/0:22 KE340296.1 3... (4 Replies)
Discussion started by: MumuGB
4 Replies

9. Shell Programming and Scripting

Bash script deleting my files, and editing files in subdirectories question

#!/bin/bash # name=$1 type=$2 number=1 for file in ./** do if then filenumber=00$number elif then filenumber=0$number fi tempname="$name""$filenumber"."$type" if (4 Replies)
Discussion started by: TheGreatGizmo
4 Replies

10. Shell Programming and Scripting

Bash Looking into files question

I have a bunch of files that are messages in my directory. Each message has a date located in the file. How can I look into each file and find the date? Thank you for any help (7 Replies)
Discussion started by: totoro125
7 Replies
qsig(1B)								PBS								  qsig(1B)

NAME
qsig - signal pbs batch job SYNOPSIS
qsig [-s signal] job_identifier ... DESCRIPTION
The qsig command requests that a signal be sent to executing batch jobs. The signal is sent to the session leader of the job. If the -s option is not specified, `SIGTERM' is sent. The request to signal a batch job will be rejected if: - The user is not authorized to signal the job. - The job is not in the running state. - The requested signal is not supported by the system upon which the job is executing. The qsig command sends a Signal Job batch request to the server which owns the job. OPTIONS
-s signal Declares which signal is sent to the job. The signal argument is either a signal name, e.g. SIGKILL, the signal name without the SIG prefix, e.g. KILL, or a unsigned signal number, e.g. 9. The signal name SIGNULL is allowed; the server will send the signal 0 to the job which will have no effect on the job, but will cause an obituary to be sent if the job is no longer executing. Not all signal names will be recognized by qsig. If it doesn't recognize the signal name, try issuing the signal number instead. Two special signal names, "suspend" and "resume", are used to suspend and resume jobs. Cray systems use the Cray-specific suspend()/resume() calls. On non-Cray system, suspend causes a SIGTSTP to be sent to all processes in job's top task, wait 5 seconds, and then send a SIGSTOP to all processes in all tasks on all nodes in the job. This differs from TORQUE 2.0.0 which did not have the abil- ity to propogate signals to sister nodes. Resume sends a SIGCONT to all processes in all tasks on all nodes. When suspended, a job continues to occupy system resources but is not executing and is not charged for walltime. The job will be listed in the "S" state. Manager or operator privilege is required to suspend or resume a job. Note that interactive jobs may not resume properly because the top-level shell will background the suspended child process. OPERANDS
The qsig command accepts one or more job_identifier operands of the form: sequence_number[.server_name][@server] STANDARD ERROR
The qsig command will write a diagnostic messages to standard error for each error occurrence. EXIT STATUS
Upon successful processing of all the operands presented to the qsig command, the exit status will be a value of zero. If the qsig command fails to process any operand, the command exits with a value greater than zero. SEE ALSO
qsub(1B), pbs_sigjob(3B), pbs_resources_*(7B) where * is system type, and the PBS ERS. Local qsig(1B)
All times are GMT -4. The time now is 01:34 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy