ksh scripting SSH to Compare File Sizes


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting ksh scripting SSH to Compare File Sizes
# 15  
Old 11-10-2018
Quote:
Originally Posted by Abstract3000
the Version of AIX I'm on
To understand which version you are on you might eventually consider some really farfetched idea, like telling us this information. Issue

Code:
oslevel -s

and post the output.

Quote:
Originally Posted by Abstract3000
i get the following error
Code:
"i++: 0403-053 Expression is not complete; more tokens expected"

I think the problem is with the missing spaces. As far as i know ksh needs spaces around the double brackets. Either this or you use ksh88 and this does not understand every infix notation. Try one of those instead (notice the additional spaces!):

Code:
(( i++ ))
(( i += 1 ))

Quote:
Originally Posted by Abstract3000
as for the Version of Ksh, I'm pretty sure it predates the paleolithic era
I don't think so. Which version exactly you have would depend on the version of AIX (see above) but in general AIX uses a ksh88 as /usr/bin/ksh and as default shell and has a ksh93 as /usr/bin/ksh93.

Quote:
Originally Posted by Abstract3000
as for the the istat (inode) command I have not tried that, looked at it previously but couldn't find any sort of modifiers or description on how to extract just the file size
istat is the correct method of getting inode information. According to this link which not only provides a thorough explanation of what it does but also a sample output it will look like:

Code:
istat /usr/bin/ksh
Inode 10360 on device 10/6    File
Protection: r-xr-xr-x
Owner: 2(bin)     Group: 2(bin)
Link count: 2     Length 372298 bytes
   
Last updated:  Wed May 13 14:08:13 1992
Last modified: Wed May 13 13:57:00 1992
Last accessed: Sun Jan 31 15:49:23 1993

therefore, to display the filesize, issue:

Code:
istat /path/to/file | sed -n '/Length/ {;s/.*Length //;s/ bytes.*//p;}'

I hope this helps.

bakunin

Last edited by bakunin; 11-10-2018 at 11:33 AM..
This User Gave Thanks to bakunin For This Post:
# 16  
Old 11-10-2018
Quote:
Originally Posted by bakunin
To understand which version you are on you might eventually consider some really farfetched idea, like telling us this information. Issue

Code:
oslevel -s

and post the output.



I think the problem is with the missing spaces. As far as i know ksh needs spaces around the double brackets. Either this or you use ksh88 and this does not understand every infix notation. Try one of those instead (notice the additional spaces!):

Code:
(( i++ ))
(( i += 1 ))

I don't think so. Which version exactly you have would depend on the version of AIX (see above) but in general AIX uses a ksh88 as /usr/bin/ksh and as default shell and has a ksh93 as /usr/bin/ksh93.

as for the the istat (inode) command I have not tried that, looked at it previously but couldn't find any sort of modifiers or description on how to extract just the file size
Thanks for taking the Time in explaining that for me. I tried a simple command that told me the version was 3, but I don't believe that is specific enough so I will give that a shot when I'm back at the terminal next week, I will also look into iNode and the Arithmetic options you gave me and see what I can gather.


Quote:
Originally Posted by Corona688
Same problem as before. Without escaping, $5 will evaluate before ssh happens.

Code:
set -A FS$i $(ssh ${HOSTS[i]} "ls -lah ${FILES[@]} | awk '{print \$5}'")


Thank you for the Explanation Smilie
This User Gave Thanks to Abstract3000 For This Post:
# 17  
Old 11-10-2018
Quote:
Originally Posted by Abstract3000
I tried a simple command that told me the version was 3
I don't know (and, in fact, can't even start to imagine) which simple command that might have been: the Korn shell comes in two "versions" (actually rather "language standards", like "FORTRAN77", than versions): "ksh88" basically means compatible to the version which was released 1988, eventually minus bugs in the original corrected since then and "ksh93" (the same but for the enhanced version released 1993).

You get the real version information for both of them in the following way: display the content of the system-variable ${.sh.version}. For my system i get:

Code:
# print - ${.sh.version}
Version AJM 93u+ 2012-08-01

This means it is a ksh93 and the version is "u+" from 2012, as ksh93 versions are "numbered" by characters: a, b, c, ... If i remember correctly the latest version of ksh93 is "w", so mine is pretty up to date.

I hope this helps.

bakunin
# 18  
Old 11-10-2018
Quote:
Originally Posted by bakunin
I don't know (and, in fact, can't even start to imagine) which simple command that might have been:
bakunin

Code:
 uname -v

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Ksh: how compare content of a file with an other array

Hi, I created a skript in ksh which generate a file with semicolon as separator, this is an example of the file a created: example content file: hello;AAAA;2014-08-17 hello;BBBB;2014-08-17 hello;CCCC;2014-08-17 I would need to compare the content in of the second column of this file... (3 Replies)
Discussion started by: jmartin
3 Replies

2. UNIX for Dummies Questions & Answers

ksh scripting, skip server if asks for password with SSH

Hi, I am running a script that connets to a list of servers with SSH and runs a command but I have some servers that are asking for password (authorized keys is not configured properly). Is there any way to do so that if I get a prompt for password just skip that entry? my script: ... (1 Reply)
Discussion started by: galuzan
1 Replies

3. Shell Programming and Scripting

Using csh / awk / sed to compare database sizes in a txt file

Hello, I have an output file showing database sizes across the 3 environments that I use (LIVE, TEST & DEVELOPMENT). I am trying to write a script that lets me know if the size of a db on one environment is different to its corresponding db on the other environments. Here is an example... (4 Replies)
Discussion started by: stevie_g
4 Replies

4. Shell Programming and Scripting

Script to compare file sizes

I need to write a bash script larger X Y that compares the sizes of two specified files X and Y, and reports which file is larger. For example, if X is larger, the output should be "File X is larger", while if Y is larger, the output should be "File Y is larger". If the files are exactly the... (3 Replies)
Discussion started by: julia_21436
3 Replies

5. UNIX for Dummies Questions & Answers

Compare two file sizes.

Hi everyone! I need to compare two file sizes. One of them (size) will be stored in a flat file and the other coming from a listed file. I can now get the first file size using: SIZE=`ls -l $DOCTYPE | awk '{print $5}'` 1. How can I store this value in a flat file? 2. How... (2 Replies)
Discussion started by: mrreds
2 Replies

6. HP-UX

compare file percent sizes

I need to get a file size and compare it to a previous day file size. If it's larger or smaller by 50 percent I'll replace the new with the old. I know how to get the file sizes but do not know how to calculate if it's 50 percent difference. Thanks for your help. (2 Replies)
Discussion started by: jkuchar747
2 Replies

7. Shell Programming and Scripting

KSH: Compare variable to $1 in an input file

Hello, I am working with KSH on AIX and I have 2 files generated from different sources... as seen below: FILE1 FILE2 AAA AAA@ABS0001C BBB BBB@ABS0003D CCC CCC@ABS0023A DDD DDD@ABC0145D EEE EEE@ABS0090A FFF FFF@ABS0002A GGG GGG@ABC0150D HHH FILE1 is main main data source,... (4 Replies)
Discussion started by: right_coaster
4 Replies

8. Shell Programming and Scripting

how to compare file sizes

hi ls -l * | sed 's/\+/ /g' | cut -f5 -d " " >out1 ls -l * | sed 's/\+/ /g' | cut -f5 -d " " >out2 diff out1 out2 i tried this it will work fine and i can see difference but i need a script which should neglect, if the difference b/w files is small and it should display... (5 Replies)
Discussion started by: revenna
5 Replies

9. Shell Programming and Scripting

to compare total directory structure and get sizes of all f on two different servers

Hello every one, Iam newbie to this forum and shell programming &scripting. i needed to compare each and every folder of two separate servers. Actually I have copied some directory structure from one server to second server, to build on second server the files all should be copied... (3 Replies)
Discussion started by: mannam srinivas
3 Replies

10. Shell Programming and Scripting

compare file sizes

Is there a command that will return the name of the largest file within a directory? If so, can I set the returned filename into a variable? (4 Replies)
Discussion started by: joli
4 Replies
Login or Register to Ask a Question