Hi,
I am fairly new to unix scripting and recently tasked with some reporting scripts.
The reporting checks several batch jobs and this is quite iterative.
Now I am trying to minimize script effort and maximize reusability as there are only slight nuances in the repetitive tasks.
For example I am herebelow trying to find the latest logfile, but for example the name is not always the same.
and other logfiles may exist in the same folder which are not interesting.
So I came up with parsing from a command (which also may differ on what you are trying to do.
now I am having some difficulty understanding why some of the parsing fails.
So I was hoping for some expert explanation, just for my understanding.
Any help would be appreciated
fyi, working in bash 3 on Solaris 11.
This fails (and I dont understand why)
obviously what I am trying to do is more complex, but I am trying to understand why it fails on the \(
This works
general pointers on approach are welcome as well
thanks
Last edited by joeniks; 01-20-2014 at 08:06 AM..
Reason: typo in code2
Just a general comment, "minimize script effort and maximize reusability" are subjective. When I write a new script my goals are [1]efficiency in processing (for example reduce the time going through a file if parsing) and [2] is this easy for someone to understand that may have to modify it. I also see you are assigning the output of ls and find to a variable. Depending on the amount of data, this could exceed the size of a variable.
No seriosuly thank you, that is probably an equally good approach, probs was just overengineering it.
a case statement teeny bit less flexible than what I was trying to achieve, but the script will indeed be more readable anyways.
I want to parse a file containing special characters, below is a sample content of file
content of file :
Serial_no:1$$@#first_name:Rahane$$@last_name:Ajiyenke@@#profession:cricketer!@#*&^
Serial_no:1$$@#first_name:Rahane$$@last_name:Ajiyenke@@#profession:cricketer!@#*&^... (3 Replies)
How to match a shell variable that contains parenthesis (and other special characters like "!")
file.txt contains:
Charles Dickens
Matthew Lewis (writer)
name="Matthew Lewis (writer)";
awk -v na="$name" ' $0 ~ na' file.txt
Ideally this would match $name in file.txt (in this... (3 Replies)
Hey guys,
I know that title is a mouthful - I'll try to better explain my struggles a little better...
What I'm trying to do is:
1. Query a db and output to a file, a list of column data.
2. Then, for each line in this file, repeat these values but wrap them with:
ITEM{
... (3 Replies)
Hello all,
I am facing with a problem of invoking an environment variable.
If I use this command :
/bin/ls -lt FILE_NM_?(20120515|20120516)??????_sas.sig | head -n1 | awk '{print $9}'
It perfectly outputs the desired result.
FILE_NM_20120516000000_sas.sig
But if I do this:... (8 Replies)
i need to replace the any special characters with escape characters like below.
test!=123-> test\!\=123
!@#$%^&*()-= to be replaced by
\!\@\#\$\%\^\&\*\(\)\-\= (8 Replies)
This has been covered many times earlier but couldnt figure the issue myself. Can you please advise whats wrong on the below code
I have a variable with special character ($) and am using that variable to replace another variable in file but however sed is failing to parse it correctly
... (7 Replies)
Hello,
I am trying the following:
echo __CHANGEME__ >> testfile
VAR1="&&&"
sed -i "s|__CHANGEME__|${VAR1}|" testfile
cat testfile
This results in testfile containing
__CHANGEME____CHANGEME____CHANGEME__
Whereas I want it to result in
&&&
I understand that if
VAR1="\&\&\&"
then... (3 Replies)
Hi,
I am getting problem in parsing special characters(Like &, > or <) in XML. I need to encode my C program and send in report format to another interface which is in XML format.
I do not know how to encode these special characters in C program before sending to XML format. Please help !! (1 Reply)
Hello-
I have a variables that contains a string like this usr/pass@SCHEMA
I want to extract the usr/pass part and ignore the SCHEMA part, I tried to use this ${dbconn%%@} and apparently it will not work because @ is a special character. I tried \@ and still no go.
Any idea how to solve... (1 Reply)