awk string comparison unterminated quoted string andrule of thumb
I have the logic below to look up for matches within the columns between the two files with awk.
In the if statement is where the string comparison is attempted with ==
The issue seems to be with the operands, as
1. when " '${SECTOR[$i]}' " -- double quote followed by single quote -- awk matches all strings without space but cannot strings with space
ex. find matches when Financials==Financials
but cannot when Consumer Cyc == Consumer Cyc and produced unterminated string error
2. when ' "${SECTOR[$i]}" ' -- single quote followed by double quote -- awk matches all strings with space but cannot strings without space
ex. find matches when Consumer Cyc == Consumer Cyc
but cannot when Financials == Financials
no error however no match and prints out sample outputs where should
Any comment is appreciated
Last edited by vbe; 10-09-2015 at 08:33 AM..
Reason: code tags please not ICODE thanks
Hi Guys,
When I am executing the script
#! /bin/bash
SARBACKUPS=/home/pradeep/sarBackups
cd /var/log/sysstat
ls -1t sar* | while read SARNAME
do
cp -p "$SARNAME" $( echo "$SARBACKUPS"/"$HOSTNAME"_"$SARNAME"_"`date +"%Y%m%d`.bkup )
done
I am getting
final.sh: 1: Syntax... (3 Replies)
here is what i want to achieve... consider a file contains below contents. the file size is large about 60mb
cat dump.sql
INSERT INTO `table1` (`id`, `action`, `date`, `descrip`, `lastModified`) VALUES (1,'Change','2011-05-05 00:00:00','Account Updated','2012-02-10... (10 Replies)
Hey guys..
New in linux scripting and need some help on some scripting with history command. I managed to export the command history into a file and now i'm trying to select from that file some specific commands that were made in a certain period. Here's what i got so far
echo -n... (2 Replies)
attempting the hangman program. This was an optional assignment from the professor. I have completed the logical coding, debugging now.
##I have an array $wordString that initializes to a string of dashes
##reflecting the number of letters in $theWord
##every time the user enters a (valid)... (5 Replies)
continuing from my previous post, whose link is given below as a reference
https://www.unix.com/shell-programming-scripting/171076-shell-scripting.html#post302573569
consider there is create table commands in a file for eg:
CREATE TABLE `Blahblahblah` (
`id` int(11) NOT NULL... (2 Replies)
Hello!
I wroted a little script that should check for new updates on a server and get them if any. The problem is, every time I run it with sh, I'm getting an "script: 20: Syntax error: Unterminated quoted string" error!
The problem is, there isn't any "unterminated quoted string" in my script:... (2 Replies)
I keep having problems when exicuting this file. It always gives me the error message "36: Syntax error: Unterminated quoted string"
If someone could help me edit this it would be much appreciated.
#!/bin/sh
#
# This will continue adding numbers
# untill the total is greater than 1,000
#... (5 Replies)
Hi
I need to update a string inside a file which looks like the following:
PX_LIST=" 4119 2390 2294 2776 2897 4099 "
Is there a way to get rid of the blanks after the first quote mark and before the last quote mark.
This needs to be done ONLY for the string named PX_LIST (there are some... (4 Replies)
While running a shell script i am getting this warning but the script is working fine.while running the blocks of the scripts individually its running fine.But while pasting it combinedly this is the warning..wat may be the reason behind this and how to resolve it (3 Replies)
I have two files with field seperator as "~".
File A: 12~13~14~15
File B: 22~22~32~11
i want to calculate the difference between two files and than calculate the percentage difference and output it to a new file.
How do i do this using awk.
Also please suggest GOOD awk tutorials.
Thank... (7 Replies)