06-17-2016
Hello,
This is not a homework. I'm just learning UNIX and that is why I posted the question here.
I'm using the sh shell
I'm looking for the last file that matches the first 3 letters ABC. There could be more than 1 file with the name ABC so I need the last one.
So I want to see if that file exist in just the folder /folder
I want to do a simple if file exist then do an echo
if not then do an echo that it doesnt
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
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)
Discussion started by: mmarsh
2 Replies
2. Shell Programming and Scripting
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)
Discussion started by: KenJo
2 Replies
3. UNIX for Advanced & Expert Users
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)
Discussion started by: alexalex1
5 Replies
4. Shell Programming and Scripting
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)
Discussion started by: prassu
1 Replies
5. Shell Programming and Scripting
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)
Discussion started by: ningy
5 Replies
6. UNIX for Dummies Questions & Answers
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)
Discussion started by: nmakkena
3 Replies
7. UNIX for Advanced & Expert Users
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)
Discussion started by: rajanikanth86
9 Replies
8. Shell Programming and Scripting
The file names are as below
a.txt.gz
a.txt
How to get the output as
.txt.gz
.txt (1 Reply)
Discussion started by: vedanta
1 Replies
9. UNIX for Dummies Questions & Answers
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)
Discussion started by: Tanu
3 Replies
10. Shell Programming and Scripting
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)
Discussion started by: erin00
3 Replies
LEARN ABOUT REDHAT
mhpath
MHPATH(1) [nmh-1.5] MHPATH(1)
NAME
mhpath - print full pathnames of nmh messages and folders
SYNOPSIS
mhpath [+folder] [msgs] [-version] [-help]
DESCRIPTION
mhpath expands and sorts the message list `msgs' and writes the full pathnames of the messages to the standard output separated by new-
lines. If no `msgs' are specified, mhpath outputs the current mail folder's pathname instead. If the only argument is `+', your nmh
"Path" is output; this can be useful in shell scripts.
Contrasted with other nmh commands, a message argument to mhpath may often be intended for writing. Because of this:
1) the name "new" has been added to mhpath's list of reserved message names (the others are "first", "last", "prev", "next", "cur", and
"all"). The new message is equivalent to the message after the last message in a folder (and equivalent to 1 in a folder without mes-
sages). The "new" message may not be used as part of a message range.
2) Within a message list, the following designations may refer to messages that do not exist: a single numeric message name, the single
message name "cur", and (obviously) the single message name "new". All other message designations must refer to at least one existing
message, if the folder contains messages.
3) An empty folder is not in itself an error.
A message number less than that of the smallest existing message in a folder is treated as if the message already exists. A message number
greater than that of the highest existing message in a folder causes an "out of range" error message to be displayed.
As part of a range designation that contains messages that do exist, message numbers less than the smallest, or greater than the highest,
existing message in a folder are ignored.
Examples: The current folder foo contains messages 3 5 6. Cur is 4.
% mhpath
/r/phyl/Mail/foo
% mhpath all
/r/phyl/Mail/foo/3
/r/phyl/Mail/foo/5
/r/phyl/Mail/foo/6
% mhpath 2001
mhpath: message 2001 out of range 1-6
% mhpath 1-2001
/r/phyl/Mail/foo/3
/r/phyl/Mail/foo/5
/r/phyl/Mail/foo/6
% mhpath new
/r/phyl/Mail/foo/7
% mhpath last new
/r/phyl/Mail/foo/6
/r/phyl/Mail/foo/7
% mhpath last-new
mhpath: bad message list last-new
% mhpath cur
/r/phyl/Mail/foo/4
% mhpath 1-2
mhpath: no messages in range 1-2
% mhpath first:2
/r/phyl/Mail/foo/3
/r/phyl/Mail/foo/5
% mhpath 1 2
/r/phyl/Mail/foo/1
/r/phyl/Mail/foo/2
mhpath is also useful in back-quoted operations:
% cd `mhpath +inbox`
% echo `mhpath +`
/r/phyl/Mail
FILES
$HOME/.mh_profile The user profile
PROFILE COMPONENTS
Path: To determine the user's nmh directory
Current-Folder: To find the default current folder
SEE ALSO
folder(1)
DEFAULTS
`+folder' defaults to the current folder
`msgs' defaults to none
CONTEXT
None
BUGS
Like all nmh commands, mhpath expands and sorts [msgs]. So don't expect
mv `mhpath 501 500`
to move 501 to 500. Quite the reverse. But
mv `mhpath 501` `mhpath 500`
will do the trick.
Out of range message 0 is treated far more severely than large out of range message numbers.
MH.6.8 11 June 2012 MHPATH(1)