Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Multiple if within while loop ksh Post 303038799 by RudiC on Friday 13th of September 2019 11:52:48 AM
Old 09-13-2019
How about
Code:
TMP=csvtxt                                                                     # extension template
while read filename
  do    IFS="._" read -A IARR <<< $filename                                    # split filename into array containing elements and extension (${IARR[-1]})
        if [ ! "${TMP/${IARR[-1]}}" = "$TMP" -a ! "${IARR[0]}" = "HELP" ] ||   # first condition  - former $A is ${IARR[0]} now
           [ ! "${IARR[2]}" = "WE" ]                                           # second condition
          then  # update table                                                 # do whatever necessary
                echo rm $filename                                              # remove echo to remove file
        fi
  done < input

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

ksh while loop

hi all, got this silly problem and i just can't seem to make sense of the error message its is saying 1400: cannot open. its my first time at writing a while loop but tried all sorts to get it working without success. #!usr/bin/ksh integer max=1400 set file="afilename" integer i=1 ... (3 Replies)
Discussion started by: scriptingmani
3 Replies

2. Shell Programming and Scripting

For loop in ksh..Please help..

Hi ALL, I need to take some command line arguments for my script and then want to run a function for each argument.I thought of using for loop as below, but its not working , can some one please help... #!/bin/ksh lpar1=$1 lpar2=$2 lpar3=$3 lpar4=$4 lpar5=$5 echo "$lpar1" >>lpar.txt echo... (4 Replies)
Discussion started by: prashant43
4 Replies

3. Shell Programming and Scripting

Help with While loop in KSH

Hi, I want to write a while loop like this can any one say me whats wrong with my loop USAGE="Usage: Mail.ksh" integer i=3 while ((1<i<=3)) do . . . . (( CMD_JUL = LSD_JUL - i )) CUR_MAINT_DATE=$(julian2date ${CMD_JUL}) . . . i=i-1 done (1 Reply)
Discussion started by: bhagya2340
1 Replies

4. Shell Programming and Scripting

Why does my for loop does not work right in ksh?

hi all, i have a for loop statement in my ksh code. it only returns the first value retrieved not the value for the other rows. ex: acct_id value = returned value in the for loop 1 = 1 2 = 1 (instead of 2) 3 = ... (1 Reply)
Discussion started by: ryukishin_17
1 Replies

5. Shell Programming and Scripting

ksh - for loop with variables

Hi, I 'm trying to send an e-mail for every different line in the .txt for i in {1..$variable} do sed -n "/$i$/p" text.txt done I have two problems about this. First one is that for loop doesn't work and the second one is that i cant get the output of sed (4 Replies)
Discussion started by: ozum
4 Replies

6. Shell Programming and Scripting

ksh loop

I need an echo "hit enter" running every 3 seconds till user hit enter key. 10x (1 Reply)
Discussion started by: LiorAmitai
1 Replies

7. Shell Programming and Scripting

ksh for loop

Any reason why this thing doesn't works in Korn Shell for (( expr1; expr2; expr3 )) do ..... ... repeat all statements between do and done until expr2 is TRUE Done Rgds, TS (4 Replies)
Discussion started by: targetshell
4 Replies

8. Shell Programming and Scripting

Reset while loop to loop same file multiple times

Hi, I want to read file multiple times. Right now i am using while loop but that is not working. ex. While read line do while read line2 do echo stmt1 #processing some data based on data., done < file2.txt done < file1.txt # This will have 10... (4 Replies)
Discussion started by: tmalik79
4 Replies

9. UNIX for Beginners Questions & Answers

Urgent.!!! Multiple if within while loop ksh

Hi All, I'm trying to write while loop with multiple if conditions. Each and every if condition with different variables. whenever one if condition fails i have remove the file from filename and have to pick another file and loop should exit until the last file found in filename. Please help... (2 Replies)
Discussion started by: Kayal
2 Replies

10. UNIX for Beginners Questions & Answers

Error with while loop ksh

while ];do first=${hat} echo "${first}" b=$((b+1)) a=$((a+5)) done I'm trying to append values from the indicated index of one array to other, but it gives me an error with while loop....suggesting that ....... In the hat array, it contains many values... (2 Replies)
Discussion started by: TestKing
2 Replies
MKSTEMP(3)						     Linux Programmer's Manual							MKSTEMP(3)

NAME
mkstemp, mkostemp - create a unique temporary file SYNOPSIS
#include <stdlib.h> int mkstemp(char *template); int mkostemp (char *template, int flags); int mkstemps(char *template, int suffixlen); int mkostemps(char *template, int suffixlen, int flags); Feature Test Macro Requirements for glibc (see feature_test_macros(7)): mkstemp(): _BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE >= 500 mkostemp(): _GNU_SOURCE mkstemps(): _BSD_SOURCE || _SVID_SOURCE mkostemps(): _GNU_SOURCE DESCRIPTION
The mkstemp() function generates a unique temporary filename from template, creates and opens the file, and returns an open file descriptor for the file. The last six characters of template must be "XXXXXX" and these are replaced with a string that makes the filename unique. Since it will be modified, template must not be a string constant, but should be declared as a character array. The file is created with permissions 0600, that is, read plus write for owner only. (In glibc versions 2.06 and earlier, the file is cre- ated with permissions 0666, that is, read and write for all users.) The returned file descriptor provides both read and write access to the file. The file is opened with the open(2) O_EXCL flag, guaranteeing that the caller is the process that creates the file. The mkostemp() function is like mkstemp(), with the difference that flags as for open(2) may be specified in flags (e.g., O_APPEND, O_SYNC). The mkstemps() function is like mkstemp(), except that the string in template contains a suffix of suffixlen characters. Thus, template is of the form prefixXXXXXXsuffix, and the string XXXXXX is modified as for mkstemp(). The mkostemps() function is to mkstemps() as mkostemp() is to mkstemp(). RETURN VALUE
On success, these functions return the file descriptor of the temporary file. On error, -1 is returned, and errno is set appropriately. ERRORS
EEXIST Could not create a unique temporary filename. Now the contents of template are undefined. EINVAL For mkstemp() and mkostemp(): The last six characters of template were not XXXXXX; now template is unchanged. For mkstemps() and mkostemps() template is less than (6 + suffixlen) characters long, or the last 6 characters before the suffix in template were not XXXXXX. These functions may also fail with any of the errors described for open(2). VERSIONS
mkostemp() is available since glibc 2.7. mkstemps() and mkostemps() are available since glibc 2.11. CONFORMING TO
mkstemp(): 4.3BSD, POSIX.1-2001. mkstemps(): unstandardized, but appears on several other systems. mkostemp() and mkostemps(): are glibc extensions. NOTES
The old behavior of creating a file with mode 0666 may be a security risk, especially since other Unix flavors use 0600, and somebody might overlook this detail when porting programs. More generally, the POSIX specification of mkstemp() does not say anything about file modes, so the application should make sure its file mode creation mask (see umask(2)) is set appropriately before calling mkstemp() (and mkostemp()). The prototype for mktemp() is in <unistd.h> for libc4, libc5, glibc1; glibc2 follows POSIX.1 and has the prototype in <stdlib.h>. SEE ALSO
mkdtemp(3), mktemp(3), tempnam(3), tmpfile(3), tmpnam(3) 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
2010-06-19 MKSTEMP(3)
All times are GMT -4. The time now is 09:59 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy