Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Unary Operator Message - Linux/Unix Post 302572889 by kxb on Friday 11th of November 2011 02:47:33 PM
Old 11-11-2011
Unary Operator Message - Linux/Unix

I have this code to check the largest files by bytes. Whenever I run it, I keep getting an error message "unary operator expected"

Code:
for i in *
do
if
set -- $(ls -ls "$i")

alias filesize='ls -lS'

[ "$i" -gt $filesize ]
then
echo $1: $5 bytes
fi
done


Last edited by jim mcnamara; 11-11-2011 at 04:01 PM.. Reason: code tags
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

unary operator expected

hi i am trying to compare a value with value 50. but i am getting " I am using if then echo "------------" fi please help thanks in advance Satya (2 Replies)
Discussion started by: Satyak
2 Replies

2. UNIX for Dummies Questions & Answers

[: =: unary operator expected

HI, while running a script, I got the below mentioned error. /bin/sh: line10 : supportedMozillaVersion() { case "$*" in *rv:1.*) return 0;; *rv:.*) return 0;; *rv:*) return 1;; Mozilla\ 1.*) return 0;; Mozilla\ .*) return 0;; *) return 1;; esac } supportedFirefoxVersion() { case... (7 Replies)
Discussion started by: bhag281
7 Replies

3. Shell Programming and Scripting

unary operator expected

Im trying to fix my /etc/weekly that rotates various logs however it does them no matter what filesize they are and i want them to only do it if there file size exceeds 2M or something. So I'm playing with a script to get the filesize using a ls -l command which works and puts the value into a... (3 Replies)
Discussion started by: timgolding
3 Replies

4. Shell Programming and Scripting

line 5: [: -gt: unary operator expected

Hello all, :confused: I am not getting this error. Pls help me. ./construct_operon.sh: line 5: #!/bin/bash # Construct Operons using gene pairs. rm -rf operons_result lines=`awk 'END {print NR}' ecoli_operons` while ; do head -1 ecoli_operons | awk '{print $1"\n"$2}' > pattern ... (5 Replies)
Discussion started by: admax
5 Replies

5. Shell Programming and Scripting

unary operator is missing

hi , i m getting an error unary operator is missing. pls check why is this so? i=5 while test $i !=0 do echo $i i=`expr $i - 1` done (3 Replies)
Discussion started by: angel12345
3 Replies

6. UNIX for Dummies Questions & Answers

[: =: unary operator expected error

Why am I getting this error.... #!/bin/sh # iOS-Ad-Remover # Marshall Ford @ marshallbford@gmail.com # This project is hosted @ http://ios-ad- # remover.sourceforge.net # Under the GNU GPL open source license clear echo if ; then echo "You need to be root to run this script."; exit 0; #... (24 Replies)
Discussion started by: mbf123
24 Replies

7. Shell Programming and Scripting

unary operator expected

i=0 while Shell script reports an error "unary operator expected" pointing the above line. $i by default is 0 and holds integer value and $buf is also holding integer value. Please can some one let me know what is missing. Thanks. (1 Reply)
Discussion started by: sunrexstar
1 Replies

8. UNIX for Dummies Questions & Answers

: unary operator expected

Hiya all, Why do I get a :unary operator expected when I try to put a condition statement in my shell script (sh) like so and how to fix? if ; then echo "say hello" else echo "don't say hello" fi ? It seems if the script receives an argument it works but if I don't put an... (4 Replies)
Discussion started by: cyberfrog
4 Replies

9. UNIX for Dummies Questions & Answers

[: -gt: unary operator expected

Hi I have problem with my script. I dont now why but i don't change anything and script stop working. this is my code: #!/bin/sh for i in `ps -A | grep pocron.sh | grep -v grep | awk '{print $2}'` do COUNT=$((COUNT+1)) done ostatnie_wykonanie=`cat porader.log`... (1 Reply)
Discussion started by: fotex
1 Replies

10. Shell Programming and Scripting

Unary operator expected

In all my Googling, this usually happens when someone is comparing a variable, and that variable is unset. That doesn't appear to be the case for me... #!/bin/bash -x while read line do f=$(echo $line | tr -s ' ' | cut -d' ' -f 3) echo $f if then echo "This... (2 Replies)
Discussion started by: jnojr
2 Replies
LFC_SETFSIZEG(3)					       LFC Library Functions						  LFC_SETFSIZEG(3)

NAME
lfc_setfsizeg - set filesize for a regular file having the given GUID; set also last modification time to the current time SYNOPSIS
#include <sys/types.h> #include "lfc_api.h" int lfc_setfsizeg (const char *guid, u_signed64 filesize, const char *csumtype, char *csumvalue) DESCRIPTION
lfc_setfsizeg sets the filesize for a regular file having the given GUID; set also the last modification time to the current time. This function should only be called by the stager after the last write operation has been performed on the file. The file is identified by its guid. guid specifies the Grid Unique IDentifier. csumtype specifies the type of checksum. Valid types are: CS standard 32 bits checksum AD Adler 32 bits checksum MD MD5 128 bits checksum RETURN VALUE
This routine returns 0 if the operation was successful or -1 if the operation failed. In the latter case, serrno is set appropriately. ERRORS
EFAULT guid is a NULL pointer. EINVAL The length of the guid exceeds CA_MAXGUIDLEN or the length of the csumtype exceeds 2 or csumtype is an unknown type or the length of the csumvalue exceeds 32. SENOSHOST Host unknown. SENOSSERV Service unknown. SECOMERR Communication error. ENSNACT Name server is not running or is being shutdown. SEE ALSO
Castor_limits(4), lfc_statg(3) LFC
$Date: 2008/09/19 11:32:26 $ LFC_SETFSIZEG(3)
All times are GMT -4. The time now is 01:53 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy