Sponsored Content
Full Discussion: File existence error
Top Forums Shell Programming and Scripting File existence error Post 302557562 by Scott on Wednesday 21st of September 2011 02:13:46 PM
Old 09-21-2011
I don't know, and without reading too much into this weird boingy stuff, -e is true if the file exists, so why do you have:

Code:
if [[ -e $new_boing ]];then
        print "There was no boing"

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Loop for file existence

I wasn't sure if I should post it here of in the Shell Script category, but I figured it was definitely a newbie question. I'm trying to write a script that will check for the existence of a specific file (or for any files within the directory) and then take specific actions. I've removed all... (2 Replies)
Discussion started by: bd_joy
2 Replies

2. Shell Programming and Scripting

File existence

Hey all, I have total new with shell scripting so I don't know if what I need to do even possible, here it is...for a duration of time (say...1 hour) I need to check for the existence of a particular file, if it exists then I will invoke a java program or I will continue to check until a)... (2 Replies)
Discussion started by: mpang_
2 Replies

3. Shell Programming and Scripting

File existence using ls

Hi I want to check a particular file is available or not. But i know only the pattern of that file sat AB1234*.txt.I need the latest file name and it ll be used in the script. How can i do this using ls -ltr command. Thanks, LathishSundar V (2 Replies)
Discussion started by: lathish
2 Replies

4. Shell Programming and Scripting

Parse file from remote server to calculate count of string existence in that file

Hi I need to parse the file of same name which exist on different servers and calculate the count of string existed in both files. Say a file abc.log exist on 2 servers. I want to search for string "test" on both files and calculate the total count of search string's existence. For... (6 Replies)
Discussion started by: poweroflinux
6 Replies

5. Shell Programming and Scripting

File existence

Hi I'm using the below command in shell script to check for file exists in the path if ..... fi path and test are variables path and the file exists but the commands inside if condition is executed (! operator used) Is the above way of checking for file existence is correct? ... (4 Replies)
Discussion started by: vinoth_kumar
4 Replies

6. Shell Programming and Scripting

Script to check for the file existence, if file exists it should echo the no of modified days

Hi, I am looking for a shell script with the following. 1. It should check whether a particular file exists in a location #!/bin/sh if ; then echo "xxx.txt File Exists" else echo "File Not Found" fi 2. If file exists, it should check for the modified date and run a command... (2 Replies)
Discussion started by: karthikeyan_mac
2 Replies

7. Shell Programming and Scripting

Find existence of file?

Hi Guys, I am using c shell script to find whether the file exist or not. I am using if statment to achieve this. I would like to tell the user which file doesn't exist and for this I would need your assistance. Example: if (! -e filename1.txt || ! -e filename2.txt || ! -e filename3.txt)... (2 Replies)
Discussion started by: dixits
2 Replies

8. Shell Programming and Scripting

Checking for the file existence

Hi, I have written a script to validate the data file by referreing to the configurtion file. And moving the validated good records and bad records into HDFS. Suppose after 15 mins if i receive one more data fie,then after validation the good and bad records shold be stored in hadoop with the... (8 Replies)
Discussion started by: shree11
8 Replies

9. Shell Programming and Scripting

File existence check

hi i wanted to check if the file exist or not(multiple files) DIRE=/home/V478 if ; then echo "file present" else echo "file not present" fi But i am getting the error as : [: unexpected operator/operand (3 Replies)
Discussion started by: ATWC
3 Replies

10. Shell Programming and Scripting

File existence

Hope someone can help me on this In a directory ,files are dynamically generated.I need a script to do the following if files are not received for more than 2 hours or if the received file is empty then do something How can I put that in a script.Thank you eg. in cd /dir_name the... (13 Replies)
Discussion started by: haadiya
13 Replies
Moose::Meta::Attribute::Native::Trait::Array(3) 	User Contributed Perl Documentation	   Moose::Meta::Attribute::Native::Trait::Array(3)

NAME
Moose::Meta::Attribute::Native::Trait::Array - Helper trait for ArrayRef attributes VERSION
version 2.0604 SYNOPSIS
package Stuff; use Moose; has 'options' => ( traits => ['Array'], is => 'ro', isa => 'ArrayRef[Str]', default => sub { [] }, handles => { all_options => 'elements', add_option => 'push', map_options => 'map', filter_options => 'grep', find_option => 'first', get_option => 'get', join_options => 'join', count_options => 'count', has_options => 'count', has_no_options => 'is_empty', sorted_options => 'sort', }, ); no Moose; 1; DESCRIPTION
This trait provides native delegation methods for array references. DEFAULT TYPE
If you don't provide an "isa" value for your attribute, it will default to "ArrayRef". PROVIDED METHODS
o count Returns the number of elements in the array. $stuff = Stuff->new; $stuff->options( [ "foo", "bar", "baz", "boo" ] ); print $stuff->count_options; # prints 4 This method does not accept any arguments. o is_empty Returns a boolean value that is true when the array has no elements. $stuff->has_no_options ? die "No options! " : print "Good boy. "; This method does not accept any arguments. o elements Returns all of the elements of the array as an array (not an array reference). my @option = $stuff->all_options; print "@options "; # prints "foo bar baz boo" This method does not accept any arguments. o get($index) Returns an element of the array by its index. You can also use negative index numbers, just as with Perl's core array handling. my $option = $stuff->get_option(1); print "$option "; # prints "bar" If the specified element does not exist, this will return "undef". This method accepts just one argument. o pop Just like Perl's builtin "pop". This method does not accept any arguments. o push($value1, $value2, value3 ...) Just like Perl's builtin "push". Returns the number of elements in the new array. This method accepts any number of arguments. o shift Just like Perl's builtin "shift". This method does not accept any arguments. o unshift($value1, $value2, value3 ...) Just like Perl's builtin "unshift". Returns the number of elements in the new array. This method accepts any number of arguments. o splice($offset, $length, @values) Just like Perl's builtin "splice". In scalar context, this returns the last element removed, or "undef" if no elements were removed. In list context, this returns all the elements removed from the array. This method requires at least one argument. o first( sub { ... } ) This method returns the first matching item in the array, just like List::Util's "first" function. The matching is done with a subroutine reference you pass to this method. The subroutine will be called against each element in the array until one matches or all elements have been checked. my $found = $stuff->find_option( sub {/^b/} ); print "$found "; # prints "bar" This method requires a single argument. o first_index( sub { ... } ) This method returns the index of the first matching item in the array, just like List::MoreUtils's "first_index" function. The matching is done with a subroutine reference you pass to this method. The subroutine will be called against each element in the array until one matches or all elements have been checked. This method requires a single argument. o grep( sub { ... } ) This method returns every element matching a given criteria, just like Perl's core "grep" function. This method requires a subroutine which implements the matching logic. my @found = $stuff->filter_options( sub {/^b/} ); print "@found "; # prints "bar baz boo" This method requires a single argument. o map( sub { ... } ) This method transforms every element in the array and returns a new array, just like Perl's core "map" function. This method requires a subroutine which implements the transformation. my @mod_options = $stuff->map_options( sub { $_ . "-tag" } ); print "@mod_options "; # prints "foo-tag bar-tag baz-tag boo-tag" This method requires a single argument. o reduce( sub { ... } ) This method turns an array into a single value, by passing a function the value so far and the next value in the array, just like List::Util's "reduce" function. The reducing is done with a subroutine reference you pass to this method. my $found = $stuff->reduce_options( sub { $_[0] . $_[1] } ); print "$found "; # prints "foobarbazboo" This method requires a single argument. o sort o sort( sub { ... } ) Returns the elements of the array in sorted order. You can provide an optional subroutine reference to sort with (as you can with Perl's core "sort" function). However, instead of using $a and $b in this subroutine, you will need to use $_[0] and $_[1]. # ascending ASCIIbetical my @sorted = $stuff->sort_options(); # Descending alphabetical order my @sorted_options = $stuff->sort_options( sub { lc $_[1] cmp lc $_[0] } ); print "@sorted_options "; # prints "foo boo baz bar" This method accepts a single argument. o sort_in_place o sort_in_place( sub { ... } ) Sorts the array in place, modifying the value of the attribute. You can provide an optional subroutine reference to sort with (as you can with Perl's core "sort" function). However, instead of using $a and $b, you will need to use $_[0] and $_[1] instead. This method does not define a return value. This method accepts a single argument. o shuffle Returns the elements of the array in random order, like "shuffle" from List::Util. This method does not accept any arguments. o uniq Returns the array with all duplicate elements removed, like "uniq" from List::MoreUtils. This method does not accept any arguments. o join($str) Joins every element of the array using the separator given as argument, just like Perl's core "join" function. my $joined = $stuff->join_options(':'); print "$joined "; # prints "foo:bar:baz:boo" This method requires a single argument. o set($index, $value) Given an index and a value, sets the specified array element's value. This method returns the value at $index after the set. This method requires two arguments. o delete($index) Removes the element at the given index from the array. This method returns the deleted value. Note that if no value exists, it will return "undef". This method requires one argument. o insert($index, $value) Inserts a new element into the array at the given index. This method returns the new value at $index. This method requires two arguments. o clear Empties the entire array, like "@array = ()". This method does not define a return value. This method does not accept any arguments. o accessor($index) o accessor($index, $value) This method provides a get/set accessor for the array, based on array indexes. If passed one argument, it returns the value at the specified index. If passed two arguments, it sets the value of the specified index. When called as a setter, this method returns the new value at $index. This method accepts one or two arguments. o natatime($n) o natatime($n, $code) This method returns an iterator which, on each call, returns $n more items from the array, in order, like "natatime" from List::MoreUtils. A coderef can optionally be provided; it will be called on each group of $n elements in the array. This method accepts one or two arguments. o shallow_clone This method returns a shallow clone of the array reference. The return value is a reference to a new array with the same elements. It is shallow because any elements that were references in the original will be the same references in the clone. BUGS
See "BUGS" in Moose for details on reporting bugs. AUTHOR
Moose is maintained by the Moose Cabal, along with the help of many contributors. See "CABAL" in Moose and "CONTRIBUTORS" in Moose for details. COPYRIGHT AND LICENSE
This software is copyright (c) 2012 by Infinity Interactive, Inc.. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. perl v5.16.2 2012-09-19 Moose::Meta::Attribute::Native::Trait::Array(3)
All times are GMT -4. The time now is 10:37 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy