How to check if pattern is matching in variable or not.
I want to check file name in variable with the pattern.
Eg: file_name="AB1000.csv"
Check for below patterns
Please advise. Thanks.
Moderator's Comments:
You have repeatedly been asked to use CODE tags when posting code, sample input data, and sample output data. Please pay attention to this simple request for you to make it easier for us to help you.
Last edited by Don Cragun; 07-31-2013 at 03:04 PM..
Reason: CODE Tags
I am new to unix and need to learn how to compare a variable $subject to a string pattern. If the variable has the word "Item" in it then it should be true. How do I do this? Currently I am using the Bourne shell but I can also use Korn or Bash.
I come from a Rexx background where strings are... (2 Replies)
dear all
i had two variable in my script.
var1 and var2
var1= 10 ( it will part of date op ) Fri Aug 8 10:05:09 IST 2008
var2=9 ( it will op of ls -ltr and time part of it.)
now i want to compare of them and want to do some task if both are are not same.
kindly let me know possible... (0 Replies)
one.txt
ONS.1287677000.820.log 20Oct2010
ONS.1287677000.123.log 21Oct2010
ONS.1287677000.456.log 22Oct2010
two.txt
ONS.1287677000.820.log:V AC CC EN
ONS.1287677000.123.log:V AC CC EN
ONS.1287677000.820.log:V AC CC EN
In file two.txt
i have to look for pattern which column one... (17 Replies)
Hello All,
I am running the below code in my script. I want if jk is empty nothing should be appened to the file total_usage.
but apparently its not happening.Kindy let me know how to do it.
###################################
jk=`ps auxf |grep -w $inputline|tr -s " "|cut -d... (0 Replies)
Please help me with this:
I need to compare two values in if condition in shell script but its goes always to else condition:
TIME_CHECK=PM
TIME-CLOCK=PM
if ; then
echo "You have access!"
else
echo "ACCESS DENIED!"
fi (5 Replies)
Here in the input file
23:59:13,devicename,21,server1,700
23:59:13,devicename,22,server2,200
23:59:13,devicename,23,server3,200
23:59:13,devicename,24,server4,200
23:59:13,devicename,25,server5,200
23:59:13,devicename,26,server6,200
23:59:13,devicename,27,server7,200... (6 Replies)
Hi,
I am writing a shell script to parse some files, and gather data.
The data in the files is displayed as below.
.......xyz: abz: ......qrt: ....
.......xyz: abz: ......qrt: ...
I have tried using awk and cut, but the position of these values keep changing, so I wasn't able to get... (2 Replies)
I have an application(Minecraft Server) that generates a logfile live. Using Crontab and screen I send a 'list' command every minute.
Sample Log view:
2013-06-07 19:14:37 <Willrocksyea1> hello*
2013-06-07 19:14:41 <Gromden29> hey
2013-06-07 19:14:42 Gromden29 lost connection:... (1 Reply)
I have two files say FILE1 and FILE2.
FILE1 contains 80,000 filename in sorted order and another file FILE2 contains 6,000 filenames is also in sorted order.
I want to compare the filename for each file and copy them in to a folder when filename is matched.
File1.txt contain 80,000... (8 Replies)
I have a file
Line 1 a
Line 22
Line 33
Line 1 b
Line 22
Line 1 c
Line 4
Line 5
I want to delete all lines before last occurrence of a line which contains something which is defined in a variable. Say a variable var contains 'Line 1', then I need the following in the output.
... (21 Replies)
Discussion started by: Soham
21 Replies
LEARN ABOUT OSX
realpath
REALPATH(3) BSD Library Functions Manual REALPATH(3)NAME
realpath -- returns the canonicalized absolute pathname
SYNOPSIS
#include <stdlib.h>
char *
realpath(const char *restrict file_name, char *restrict resolved_name);
DESCRIPTION
The realpath() function resolves all symbolic links, extra ``/'' characters, and references to /./ and /../ in file_name. If the
resolved_name argument is non-NULL, the resulting absolute pathname is copied there (it must refer to a buffer capable of storing at least
PATH_MAX characters).
As a permitted extension to the standard, if resolved_name is NULL, memory is allocated for the resulting absolute pathname, and is returned
by realpath(). This memory should be freed by a call to free(3) when no longer needed.
The realpath() function will resolve both absolute and relative paths and return the absolute pathname corresponding to file_name. All com-
ponents of file_name must exist when realpath() is called.
RETURN VALUES
On success, the realpath() function returns the address of the resulting absolute pathname, which is resolved_name if it was non-NULL, or the
address of newly allocated memory. If an error occurs, realpath() returns NULL. If resolved_name was non-NULL, it will contains the path-
name which caused the problem.
VARIANTS
Defining _DARWIN_C_SOURCE or _DARWIN_BETTER_REALPATH before including stdio.h will cause the provided implementation of realpath() to use
F_GETPATH from fcntl(2) to discover the path.
ERRORS
The function realpath() may fail and set the external variable errno for any of the errors specified for the library functions alloca(3),
getattrlist(2), getcwd(3), lstat(2), readlink(2), stat(2), and strdup(3).
LEGACY SYNOPSIS
#include <sys/param.h>
#include <stdlib.h>
The include file <sys/param.h> is necessary.
LEGACY DESCRIPTION
In legacy mode, the last component of file_name does not need to exist when realpath() is called.
SEE ALSO free(3), getcwd(3), compat(5)HISTORY
The realpath() function first appeared in 4.4BSD.
BSD April 5, 2008 BSD