Sponsored Content
Full Discussion: What's wrong on this script?
Top Forums UNIX for Dummies Questions & Answers What's wrong on this script? Post 302583148 by radoulov on Monday 19th of December 2011 05:47:15 PM
Old 12-19-2011
Which OS are you using? You can achieve most of that with a single command.

This is the content of my home directory:

Code:
zsh-4.3.14[sysadmin]% ls -lhA
total 38M
-rwxr-xr-x  1 Administrators None  698 Nov  3  2008 .Xdefaults
-rwxr-xr-x  1 Administrators None 3.2K Nov 21 15:44 .aliases
-rwxr-xr-x  1 Administrators None  16K Dec 19 20:14 .bash_history
-rwxr-xr-x  1 sysadmin       None 1.2K Nov 11 21:10 .bash_profile
-rwxr-xr-x  1 sysadmin       None 3.7K Oct  7 22:45 .bashrc
drwxr-xr-x+ 1 sysadmin       None    0 Dec 19 22:40 .cpan
-rwxr-xr-x  1 Administrators None 1.1K Mar 22  2010 .exp
-rwxr-xr-x  1 Administrators None  373 Mar 22  2010 .exp_1
-rwxr-xr-x  1 Administrators None 579K Dec 19 21:53 .histfile
-rw-------  1 sysadmin       None 2.3K Nov 28 21:30 .history
-rwxr-xr-x  1 sysadmin       None 1.6K Nov 14 23:35 .inputrc
-rwxr-xr-x  1 Administrators None   30 Dec 30  2008 .kshrc
-rw-------  1 Administrators None  370 Dec 19 23:41 .lesshst
drwx------+ 1 sysadmin       None    0 Oct  5 16:13 .mc
-rwxr-xr-x  1 sysadmin       None 8.9K Jul 24 02:30 .mkshrc
drwxr-xr-x+ 1 sysadmin       None    0 Nov 16 15:16 .parallel
-rwxr-xr-x  1 sysadmin       None   10 Oct 16 15:03 .profile
-rw-------  1 sysadmin       None 2.9K Dec 13 22:14 .sh_history
-rw-------  1 sysadmin       None 3.7K Nov 23 13:21 .sqlplus_history
drwx------+ 1 sysadmin       None    0 Oct 20 11:25 .ssh
-rw-r--r--  1 sysadmin       None  33K Dec  7 23:13 .zcompdump
-rwxr-xr-x  1 Administrators None 2.6K Nov  8 13:14 .zshrc
-rw-r--r--  1 sysadmin       None  37M Dec 13 22:13 Measuring Scalability and Performance with TCP, Baron Schwartz, Percona.wmv
-rw-r--r--  1 sysadmin       None    0 Nov 28 21:20 an exe
-rwxr-xr-x  1 sysadmin       None  320 Dec 19 20:12 bash.exe.stackdump
-rw-r--r--  1 sysadmin       None  143 Nov 11 23:48 passwd
lrwxrwxrwx  1 sysadmin       None   30 Nov 23 11:45 scripts -> /cygdrive/f/operations/scripts
-rwxr-xr-x  1 sysadmin       None  318 Dec 19 19:47 sh.exe.stackdump
-rw-r--r--  1 sysadmin       None  122 Nov 11 23:48 shadow
drwxr-xr-x+ 1 sysadmin       None    0 Dec 17 23:29 stagearea
drwxr-xr-x+ 1 sysadmin       None    0 Dec 19 22:50 t

The following command will display the files between 10 and 1000k:

Code:
zsh-4.3.14[sysadmin]% find . -maxdepth 1 -type f  -size +10k -a ! -size +1000k -printf '%f -> %kk\n' 
.bash_history -> 8k
.histfile -> 290k
.zcompdump -> 18k

Note that most of the options used in the above find command are not standard (i.e. they are not available on most Unix systems),
but the important one -size is usually available (with limited argument modifiers).

P.S. I'm not sure why 8k is in the output Smilie

P.P.S. Perhaps this should be more appropriate example:

Code:
zsh-4.3.14[sysadmin]% find . -maxdepth 1 -type f  -size +10k -a ! -size +1024k  -exec ls -lh {} +
-rwxr-xr-x 1 Administrators None  16K Dec 19 20:14 ./.bash_history
-rwxr-xr-x 1 Administrators None 579K Dec 19 21:53 ./.histfile
-rw-r--r-- 1 sysadmin       None  33K Dec  7 23:13 ./.zcompdump

Code:
              The size does not count indirect blocks, but it does count blocks in sparse files that are not actually
              allocated.   Bear  in mind that the `%k' and `%b' format specifiers of -printf handle sparse files dif-
              ferently.  The `b' suffix always denotes 512-byte blocks and never 1 Kilobyte blocks, which is  differ-
              ent to the behaviour of -ls.


Last edited by radoulov; 12-19-2011 at 06:53 PM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

What is wrong with my script?

Hey guys, can someone help me with this script... #!/bin/sh dir=`pwd` for i in *.f do if then M=`wc -l < ${i} sed -e 's://.*::' < ${i} | \ (echo "//${i} -"$M ; cat - ) > $i.tmp chmod 700 $i ; mv ${i}.tmp $i ... (6 Replies)
Discussion started by: Lem2003
6 Replies

2. Shell Programming and Scripting

What is wrong with this script?

I keep getting errors messages for the "else" statement at line 81? #!/bin/ksh ######### Environment Setup ######### PATH=/gers/nurev/menu/pub/sbin:/gers/nurev/menu/pub/bin:/gers/nurev/menu/pub/mac :/gers/nurev/menu/adm/sbin:/gers/nurev/menu/adm/bin:/gers/nurev/menu/adm/mac:/ge... (8 Replies)
Discussion started by: heprox
8 Replies

3. Shell Programming and Scripting

What's wrong with this script

I am trying to create a script but it is giving me errors on Cygwin for the following script. Could someone tell me, what am I doing wrong? choice=1000 echo "choice is $choice" while ; do echo "choice is $choice" echo 'Please select your option:' echo '1. Option 1' echo '2. Option 2'... (3 Replies)
Discussion started by: amitg1980
3 Replies

4. UNIX for Dummies Questions & Answers

what is wrong with this script?

Hi, I have this example script which gives error ": unexpected operator/operand". I need the '' brackets for operator precedence. #!/bin/ksh x="abc" y="xyz" z="123" if -a then print "yes" else print "no" fi Thanks (2 Replies)
Discussion started by: rs1969
2 Replies

5. Shell Programming and Scripting

what is wrong with this script?

Hi I've made a short script but it is not working. Can some pl. help me out in this? ./123.sh #! /usr/bin/ksh # for changing to this directory cd /layered/relational/scripts When I run the above scripts, it doesn't change to the above directory. I don't what is the problem? the... (2 Replies)
Discussion started by: Mike1234
2 Replies

6. Shell Programming and Scripting

Script Gone Wrong

Hello all, so this is a script i did for an assignement, - first option greets the user according to the time after fetching his name - second options isn't implemented - third check the performance according to how many users are using the system - creates a log of names, time and ip of the... (14 Replies)
Discussion started by: ibzee33
14 Replies

7. Shell Programming and Scripting

What's wrong with my script ....

Please see below mentioned my script ... it ran once without any issue .... then after it is not coming out .... please suggest what is wrong? #!/bin/ksh ## if (( ${num_errors} > 0 )); export ACULOG=/home/varshnes/input export num_errors=10 **** Search for 'Start correcting roll up... (7 Replies)
Discussion started by: heyitsmeok
7 Replies

8. Shell Programming and Scripting

Can anyone tell me what's wrong with my script

Hi... I am fed up in file handing with array for comparing.... 1st I want save first 2 columns of file 1 I tried like this,, {getline< "file1";ln=$1; lt=$2}then I read second file's 1st and 2nd column..and saved like this and small calculation and initialization var1 =$1 var2 =$2... (5 Replies)
Discussion started by: Akshay Hegde
5 Replies

9. Shell Programming and Scripting

What is wrong with my script?

Dear All The following is part of my script: echo ${myarray} mytitle=`awk '{print substr(${myarray}, 0, length(${myarray})-4)}' /dev/null` the echo ${myarray} works fine; however, I keep getting following error for the mytitle=.. part: awk: line 1: syntax error at or near { awk: line... (3 Replies)
Discussion started by: littlewenwen
3 Replies

10. Shell Programming and Scripting

Why result is wrong here ? whether break statement is wrong ?

Hi ! all I am just trying to check range in my datafile pls tell me why its resulting wrong admin@IEEE:~/Desktop$ cat test.txt 0 28.4 5 28.4 10 28.4 15 28.5 20 28.5 25 28.6 30 28.6 35 28.7 40 28.7 45 28.7 50 28.8 55 28.8 60 28.8 65 28.1... (2 Replies)
Discussion started by: Akshay Hegde
2 Replies
All times are GMT -4. The time now is 07:07 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy