Sponsored Content
Full Discussion: Nested if in KSH
Top Forums Shell Programming and Scripting Nested if in KSH Post 302566081 by Calbrenar on Wednesday 19th of October 2011 12:06:01 PM
Old 10-19-2011
I was unable to find a better way to get ls to list by modified times and not include directories. I tried various solutions but the directories were always included.

I will try your suggestion for the if and reply thanks.

---------- Post updated at 11:58 AM ---------- Previous update was at 11:46 AM ----------

Code:
for i in `ls -pcr | grep -v [\/] `
do
                echo "PRE; $PREMID_DT_TM and Post; $POSTMID_DT_TM"
        if [ -e ${i} ]
        then
            echo "Processing file ${i}"      
            TEMP=$(echo "${i}" | sed -e "s/$PREMID_DT_TM/$POSTMID_DT_TM/")
          if [[ "${i}" != "${TEMP}" ]]
                    then
                   mv ${i} ${TEMP}
                    fi
        fi
done

it's saying the then is unexpected.

Also i think I tried testing for inequality first i just kept trying different examples on google trying to get it to work.



Last edited by Calbrenar; 10-19-2011 at 01:08 PM.. Reason: duplicate due to network latency
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Nested calls

Hi all, I have two questions: 1. I have a script (call it A) that call another script (call it B) which in turn call another script (call it C). The strange thing is that when script C hangs script A exists (i.e., will not appear when I call ps command to list all the running processes). Is my... (6 Replies)
Discussion started by: omran
6 Replies

2. Shell Programming and Scripting

nested variables

Is there any way to do variable nesting using sh? For example: example_1="a test string" example_2="another test" example_3="etc..." i=2 echo ${example_$i} The shell reports: sh: ${example_$i}: bad substitution If not, maybe someone could suggest another method. Thanks in... (3 Replies)
Discussion started by: kevinl33
3 Replies

3. Shell Programming and Scripting

KSH script to run other ksh scripts and output it to a file and/or email

Hi I am new to this Scripting process and would like to know How can i write a ksh script that will call other ksh scripts and write the output to a file and/or email. For example ------- Script ABC ------- a.ksh b.ksh c.ksh I need to call all three scripts execute them and... (2 Replies)
Discussion started by: pacifican
2 Replies

4. Shell Programming and Scripting

Nested while loops (ksh scripting)

You can use one while inside another? I made the following script (without really knowing if I can use two while) to get 3 numbers different from each other at random: num1=$(( $RANDOM % 10 )) num2=$num1 while do num2=$(( $RANDOM % 10 )) done num3=$num1 while do while do... (1 Reply)
Discussion started by: ale.dle
1 Replies

5. Shell Programming and Scripting

Nested If condition

Hi I have a requirement to create a 2 folder based on there existance if then cd $var_name if then cd $var_name3 mv -fi *.* $var_TargetPath/$var_name/$var_name3 else mkdir -p "$var_name3" chmod 755 "$var_name3" mv -fi *.* $var_TargetPath/$var_name/$var_name3 else mkdir... (7 Replies)
Discussion started by: magesh_bala
7 Replies

6. Shell Programming and Scripting

KSH nested loops?

KSH isn't my strong suit but it's what my company has to offer. I've got a script with two nested loops, a FOR and UNTIL, and that works fine. When I add a CASE into the mix I end up getting "Unexpected 'done' at line xx" errors. Any suggestions on this? for divi in at ce ci cm co de di fl... (9 Replies)
Discussion started by: mrice
9 Replies

7. Shell Programming and Scripting

Nested case

Hi there, I have nested case in my script. I am asking user, want to continue? if user press y/Y then my inner case should continue, rather than that my code start from beginning. I would like to continue my inner case until user press n or N. Is any one tell me how can I do? Thanking You,... (2 Replies)
Discussion started by: kasparov
2 Replies

8. Shell Programming and Scripting

Nested if else

Hi, i m trying to create script which logic is like below. if ; then x=`cat /tmp/testoutput.log | grep STOP | wc -l` y=`cat /tmp/testoutput.log | grep RUN | wc -l` if ; then echo "process stop" if ; then echo "process running " else echo "file not found" fi ----------------... (2 Replies)
Discussion started by: tapia
2 Replies

9. Shell Programming and Scripting

ksh - Need Help Reducing Nested Loops

Hello, I pulled out some old code from an unfinished project the other day and wanted to stream line it better. I know anything beyond a double loop is usually bad practice, and I came up with some logic for later that would no longer require the first loop in the following code that works: ... (5 Replies)
Discussion started by: Azrael
5 Replies
UNSQUASHFS(1)						  uncompress squashfs filesystems					     UNSQUASHFS(1)

NAME
mksquashfs - tool to uncompress squashfs filesystems SYNOPSIS
unsquashfs [OPTIONS] FILESYSTEM [directories or files to extract] DESCRIPTION
Squashfs is a highly compressed read-only filesystem for Linux. It uses zlib compression to compress both files, inodes and directories. Inodes in the system are very small and all blocks are packed to minimize data overhead. Block sizes greater than 4K are supported up to a maximum of 64K. Squashfs is intended for general read-only filesystem use, for archival use (i.e. in cases where a .tar.gz file may be used), and in con- strained block device/memory systems (e.g. embedded systems) where low overhead is needed. OPTIONS
-v, -version print version, licence and copyright information. -d PATHNAME, -dest PATHNAME unsquash to PATHNAME, default "squashfs-root". -n, -no-progress don't display the progress bar. -no, -no-xattrs don't extract xattrs in file system. -x, -xattrs extract xattrs in file system (default). -p NUMBER, -processors NUMBER use NUMBER processors. By default will use number of processors available. -i, -info print files as they are unsquashed. -li, -linfo print files as they are unsquashed with file attributes (like ls -l output). -l, -ls list filesystem, but don't unsquash. -ll, -lls list filesystem with file attributes (like ls -l output), but don't unsquash. -f, -force if file already exists then overwrite. -s, -stat display filesystem superblock information. -e EXTRACT_FILE, -ef EXTRACT_FILE list of directories or files to extract. One per line. -da SIZE, -data-queue SIZE Set data queue to SIZE Mbytes. Default 256 Mbytes. -fr SIZE, -frag-queue SIZE Set fragment queue to SIZE Mbytes. Default 256 Mbytes. -r, -regex treat extract names as POSIX regular expressions rather than use the default shell wildcard expansion (globbing). Decompressors available gzip lzo xz SEE ALSO
mksquashfs(1) HOMEPAGE
More information about unsquashfs and the squashfs filesystem can be found at <http://squashfs.sourceforge.net/>. AUTHOR
squashfs was written by Phillip Lougher <plougher@users.sourceforge.net>. This manual page was written by Daniel Baumann <daniel.baumann@progress-technologies.net>. 4.2 2012-06-30 UNSQUASHFS(1)
All times are GMT -4. The time now is 08:25 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy