I get an error if there is no ABC* files on the folder, do you know why?
Moderator's Comments:
Please use CODE tags when displaying sample code segments, sample input files, and sample output files (as required by forum rules.
Did you try your if statement above? If you did try it, what did it do? If you didn't try it, why not? You said you wanted an echo if the file is there and an echo if there is no matching file. I don't see anything in that if command that would echo anything if no matching file is found.
In post #2 in this thread, the first request I made was: "... please tell us ... what operating system you're using". Without an answer to that question we don't know whether sh on your system is a legacy Bourne shell (traditional sh), a 1988 vintage Korn shell with POSIX extensions (frequently called ksh), bash, dash, zsh, or some other less common shell.
If the if statement above is working, we know that you are not using a traditional Bourne shell.
There are several things wrong with the variable assignment statement above, none of which would complain about non-existent /folder/ABC* with any of the shells that would be installed with the name sh on common UNIX systems, Linux systems, or BSD systems. These problems include, but might not be limited to:
There cannot be any spaces around the =.
A traditional Bourne shell command substitution (which would be accepted by any of the above shells) uses back-quote characters (`) not single-quote ('). (And, unless you are using a traditional Bourne shell, the back-quote method of of performing command substitutions (`command`) is obsolete and should never be used: use the $(command) form of command substitution instead).
When asking for help, please ALWAYS show us the exact diagnostic message produced by the system and the exactly command that you typed into the shell that produced the error message.
With the command:
the error that would be expected on most systems would be something like:
With an incorrectly configured Apple OS X operating system (where the standard utilities are installed in a case-insensitive filesystem) you might get something like:
because with spaces around the assignment operator, this is an attempt to run the FILE command with the two operands:
and
You might also get an error like that on a Cygwin subsystem running on a Windows operating system, but I haven't tried this on Cygwin.
I have a log file which have a date and time at the start of every line.
I need to search the log file starting from a specific time to the end of file.
For example:
Starting point: July 29 2018 21:00:00
End point : end of file
My concern is what if the pattern of `July 29 2018 21:00:00`... (3 Replies)
e.g.
File name: File.txt
cat File.txt
Result:
#INBOUND_QUEUE=FAQ1
INBOUND_QUEUE=FAQ2
I want to get the value for one which is not commented out.
Thanks, (3 Replies)
Hi,
I have a query:
I have a bunch of files starting letter with 'a'
(example: abhi,all,anand,animal,a1.txt,allow.java,a*)
here i want to delete/remove only a* folder but not other files and folders. and a* folder is present in so many other folders.
what is unix command to delete... (9 Replies)
Hi
I am very new to unix and please help me in solving the below problem
I have a file with 50000+ rows. Each row(line) start with 01 or 02 or 03.
Now i have to get the count of rows starting with 01 only,
Thanks in advance (3 Replies)
I am trying to check if files staring with filename but ending with diffent dates e.g. filename.2011-10-25.
The code I am using is below
if
It works find only if one file is present but returns binary operator expected
when there are mulptiple files.
Please help me correcting it. I... (5 Replies)
Hi,
I have lets say 10 files , I need to process them one by one.
So I need a command to get one file name at a time to process it into a variable
Example
Files
P1111.dat
P3344.dat
S344.dat
...
v_file_name = 'p111.dat' .. I will rename it to something after processing
... (1 Reply)
Advance Thanks.
(1) I would like to know any unix/Linux command to check EOF char in a file.
(2) Or Any way I can check a file has been reached completely at machine B from machine A. Note that machine A ftp/scp the file to machine B at unknown time. (5 Replies)
helo all
I have a file where lines start with ~|.
Given a sample line-> ~|21|123|1232|ABC|2135....
So when i use the command
-----cat $file | mailx -s "Rejects : $envid" $recip.dat------
When unix cats the file which holds lines starting with ~| it seems to be it takes those lines... (2 Replies)
I wish to seach a Dir for a specific file, once the file is found i will perform additional logic. If the file is not found within two hours, i would like to exit.
Logically, I'm looking for the best way to approach this
Thanks for any assistance in advance.
Note: I'm using a C shell and... (2 Replies)