-gt option in UNIX


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting -gt option in UNIX
# 8  
Old 02-04-2019
Quote:
Originally Posted by onenessboy
what does that -gt option represents ?
numerical comparison.
Quote:
integers can only be compared with:
-eq # equal
-ne # not equal
-lt # less than
-le # less than or equal
-gt # greater than
-ge # greater than or equal

Last edited by jim mcnamara; 02-04-2019 at 09:43 AM..
# 9  
Old 02-04-2019
Quote:
Originally Posted by RudiC
First logical error:COUNT=$(echo "${BACKUPLIST}" | wc -l). Guessing you want that file's line count, try
Code:
COUNT=$(<"${BACKUPLIST}"  wc -l)

Probably not. The way threads O/P showed the string in #1 the string contains filenames separated by newlines and the command results in the number of filenames then. I don't say this is a good idea but under these circumstancs it at least makes sense:

Code:
x='first line
second line
third line'
echo "$x" | wc -l
3

I hope this helps.

bakunin
This User Gave Thanks to bakunin For This Post:
# 10  
Old 02-04-2019
Oohhh. Yes, if you look at it from this aspect, the echoing of the variable makes some sense; I was wrong. I interpreted $BACKUPLIST to point to a file listing the backups.
Thanks for pointing this out.


Wouldn't it make more sense to use a shell array (saving running many external commands) to achieve the same goal? Like
Code:
$ IFS=$'\n'
$ BCKARR=(${BACKUPLIST})
$ echo ${#BCKARR[@]}
3
$ if [ ${#BCKARR[@]} -gt $RESTOREPOINTS ]
>    then START=${BCKARR[0]}
>         END=${BCKARR[${#BCKARR[@]}-$RESTOREPOINTS]}
>    fi

Hmmm - I see nezabudka was on the same track.

Last edited by RudiC; 02-04-2019 at 02:40 PM..
This User Gave Thanks to RudiC For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

Unrecognized option: sparc-sun-Solaris2.10/bin/as: unrecognized option `-m32'

Hi, I installed some packages required by an app built with python. But when I try python setup.py install, I get the following error: /opt/csw/lib/gcc/sparc-sun-solaris2.10/5.2.0/../../../../sparc-sun-solaris2.10/bin/as: unrecognized option `-m32' Could anyone tell me what's wrong... (4 Replies)
Discussion started by: Kimkun
4 Replies

2. Shell Programming and Scripting

Unix Find with exec option.

All, I am using following find command to see all the files with specified pattern : find /exp/source -exec grep -li "SIT_MARKET" {} \; say , the /exp/source has n number of subdirectories and each subdirectory has its own directory tree. If this is the case I will get a result... (9 Replies)
Discussion started by: kanu_kanu
9 Replies

3. Shell Programming and Scripting

Request for file read option in Unix shell scripting

Hi Friends, I would like to read all the record from one txt file to other file txt For example I have two txt file a.txt and b.txt. I need to read a.txt record by record and I need add the system date @ end of each record before moving it to b.txt. Could you please share the coding for... (4 Replies)
Discussion started by: vinoth124
4 Replies

4. Shell Programming and Scripting

recently introduced to the newer option for find...does an older option exist?

To find all the files in your home directory that have been edited in some way since the last tar file, use this command: find . -newer backup.tar.gz Is anyone familiar with an older solution? looking to identify files older then 15mins across several directories. thanks, manny (2 Replies)
Discussion started by: mr_manny
2 Replies

5. Shell Programming and Scripting

unix find command without mmin option

I need to check if a file has been modified within the last x hours. My find command does not have the mmin option -- only the mtime option which is in 24 hour perriods (1 Reply)
Discussion started by: Bill Ma
1 Replies

6. Shell Programming and Scripting

Unix mail with bcc option

Hello Everyone, I'm using UNIX 5.3, I'm using command line mailx or mail command to send emails to multiple email addresses and i need to include bcc (background corbon copy). Some Manuals says i can use -b flag to send to bcc but my unix does not recognize the flag "-b". And some manuals says... (1 Reply)
Discussion started by: aravindbachu
1 Replies

7. Shell Programming and Scripting

Unix Shell Script: With Menu Option

I am attempting to create a shell script with the following capaciblities: 1. Listed options to choice from 2. Use to perform awk statements 3. Print a report with the awk results My questions are 1. How do I select more than one file for option #5 and #6 2. How to I create an... (11 Replies)
Discussion started by: jroberson
11 Replies

8. Shell Programming and Scripting

what is -u option in while loop in unix

Hi all, What does -u option in while loop indicates in unix? ex: while read -u field (1 Reply)
Discussion started by: krishna_gnv
1 Replies

9. Shell Programming and Scripting

option followed by : taking next option if argument missing with getopts

Hi all, I am parsing command line options using getopts. The problem is that mandatory argument options following ":" is taking next option as argument if it is not followed by any argument. Below is the script: while getopts :hd:t:s:l:p:f: opt do case "$opt" in -h|-\?)... (2 Replies)
Discussion started by: gurukottur
2 Replies

10. UNIX for Dummies Questions & Answers

UNIX chauthtok(): illegal module option

Hi all, I just implemented PAM on my Solris 8/9 boxes and one of the entries I have got in the /etc/pam.conf is as followed, other password required pam_unix.so nullok remember=7 md5 shadow use_authtok However, once I set this and the following meesages appears in /var/adm/messages... (1 Reply)
Discussion started by: stancwong
1 Replies
Login or Register to Ask a Question