Results 1 to 10 of 11
I do this
Code:
set index = 1
set limit = `expr $#values - 1`
while ($index <= $limit)
set value = $values[$index]
echo $value
# calculate the size of ...
- 08-15-2007 #1Just Joined!
- Join Date
- Jul 2007
- Posts
- 31
"xargs: unmatched single quote" why this erorr message (code inside)
I do this
Code:set index = 1 set limit = `expr $#values - 1` while ($index <= $limit) set value = $values[$index] echo $value # calculate the size of files within a specific period: set fsize = `find -mtime -$value -type f | xargs ls -tg | awk '{ size += $4 } END {print size}'` # for testing: echo $fsize # calculate the next index: set nextIndex = `expr $index + 1` set value = $values[$nextIndex] echo $value # calculate the size of files within the next specific period: set fsize2 = `find -mtime -$value -type f | xargs ls -tg | awk '{ size2 += $4 } END {print size2}' ` # for testing: echo $fsize2 # calculate the difference: set defsize = `expr $fsize - $fsize2` # for testing: echo defrance # for testing: echo $defsize # write into file: echo " $values[$index] ${defsize}" >> outputISP2 # update index: set index = `expr $nextIndex` echo "------------------------------" echo $index echo "------------------------------" end
it work but not properly
give the result correct but for just 2 of 6 of array (720 ,580 ) but the other give dash "-"
and error message
"xargs: unmatched single quote"
- 08-15-2007 #2
What are the values of $value for which xargs fails? What is the find output for each of these values?
DISTRO=Arch
Registered Linux User #388732
- 08-15-2007 #3Just Joined!
- Join Date
- Jul 2007
- Posts
- 31
sorry I miss this line in the code
set values = (720 580 360 270 120 90 0)
output of find is the size of each value (720 580 360 270 120 90 0)Code:set values = (720 580 360 270 120 90 0) set index = 1 set limit = `expr $#values - 1` while ($index <= $limit) set value = $values[$index] echo $value # calculate the size of files within a specific period: set fsize = `find -mtime -$value -type f | xargs ls -tg | awk '{ size += $4 } END {print size}'` # for testing: echo $fsize # calculate the next index: set nextIndex = `expr $index + 1` set value = $values[$nextIndex] echo $value # calculate the size of files within the next specific period: set fsize2 = `find -mtime -$value -type f | xargs ls -tg | awk '{ size2 += $4 } END {print size2}'` # for testing: echo $fsize2 # calculate the difference: set defsize = `expr $fsize - $fsize2` # for testing: echo defrance # for testing: echo $defsize # write into file: echo " $values[$index] ${defsize}" >> outputISP2 # update index: set index = `expr $nextIndex` echo "------------------------------" echo $index echo "------------------------------" end this line in the code
- 08-15-2007 #4
- 08-15-2007 #5
No, I mean the output of just:
Also, you may be interested:Code:find -mtime -$value -type f
Csh Programming Considered HarmfulDISTRO=Arch
Registered Linux User #388732
- 08-15-2007 #6
- 08-16-2007 #7
Now that I think about it, the problem with your program may just be the C Shell, and may be entirely unrelated to the actual script.
Try rewriting your script as a Bash script and see if that fixes it.DISTRO=Arch
Registered Linux User #388732
- 08-18-2007 #8Just Joined!
- Join Date
- Jul 2007
- Posts
- 31
yes it isIs this c shell?
How?Try rewriting your script as a Bash script and see if that fixes it.
output is the files that modify in specific period of time which is $value (enter by user)No, I mean the output of just:
Code:
find -mtime -$value -type f
- 08-18-2007 #9
What I wanted was for you to post the exact output, as if you had run that command yourself. I know what it's supposed to output; I wanted to see what it actually output.
Anyway, to rewrite it in Bash, learn how to script in Bash. A good new user guide is:
http://tldp.org/LDP/Bash-Beginners-G...ers-Guide.html
And a fantastic advanced guide/reference is:
http://www.tldp.org/LDP/abs/html/
Most things will directly translate, it's just a matter of different syntax. Bash is basically the universal Linux shell, and as described in my link about csh scripting, has many advantages over csh for scripting.DISTRO=Arch
Registered Linux User #388732
- 08-19-2007 #10Just Joined!
- Join Date
- Jul 2007
- Posts
- 31
this should be the output
720
298436410
580
133149854
differenc
165286556
------------------------------
2
------------------------------
580
133149871
360
2549625
difference
130600246
------------------------------
3
------------------------------
360
2549625
270
1000000
difference
1549625
------------------------------
4
------------------------------
270
1000000
120
900000
difference
100000
------------------------------
5
------------------------------
120
900000
90
100000
difference
800000
------------------------------
6
------------------------------
90
100000
0
0
difference
100000
------------------------------
7
------------------------------
720 165286556
580 130600246
360 1549625
270 100000
120 800000
90 100000
0 0
I must use c shell to come with this output


Reply With Quote
