Find the answer to your Linux question:
Results 1 to 2 of 2
I have this c shell code but give strange error when I run it echo "" > tmpfile foreach priod ( 720 580 360 270 180 90 ) set fsize ...
  1. #1
    Just Joined!
    Join Date
    Jul 2007
    Posts
    31

    Unhappy I have c shell code but give strange error

    I have this c shell code but give strange error when I run it

    echo "" > tmpfile
    foreach priod ( 720 580 360 270 180 90 )
    set fsize = `find -mtime priod | xargs ls -tg | awk '{ size += $4 } END {print size}' `
    echo " ${priod} ${fsize}" >> tmpfile
    end
    end

    it give this error

    find: invalid argument `priod' to `-mtime'
    find: invalid argument `priod' to `-mtime'
    find: invalid argument `priod' to `-mtime'
    find: invalid argument `priod' to `-mtime'
    find: invalid argument `priod' to `-mtime'
    find: invalid argument `priod' to `-mtime'


    end: Not in while/foreach.


    this code should be try to find All file and display them sort by time
    I give example (( 720 580 360 270 180 90 ))
    it go foreach period and add size and print it + the period
    for example it goes for 270 fined all file from 180 day (6 month) add size of all file print period +size
    like
    180 2333345

    and so on

    like
    30 3333523
    60 4000000
    90 5349943
    120 6900000
    150 7002345
    180 80032443
    210 92423243

  2. #2
    scm
    scm is offline
    Linux Engineer
    Join Date
    Feb 2005
    Posts
    1,044

    Post

    It's been a while since I was foolish enough to write scripts for the c shell, but try putting a $ in front of your priod in the find command.
    Code:
    find -mtime $priod

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...