Problem passing a search pattern to AWK inside a script loop
Learning, stumbling! My progress in shell scripting is slow. Now I have this doubt:
I have the following file (users.txt):
And this file (userson.txt)
I just want to set those users on userson.txt to "off" in the users.txt file. String substitution.
This is an exercise with AWK, I already know other methods to change it but I'm interested in AWK.
Now, I tried this in a script:
Script1.sh
That works for that given string, but I for hours I can't see why this does not work:
The variable is passed correctly (read from usersons.txt) as I already tried printing it with no search pattern and it did print. I just can't see how the loop is preventing this simple command to work.
Any clues?
Last edited by quinestor; 03-13-2012 at 04:45 PM..
This is strange. What OS are you using and what shell?
Is userson.txt exactly like in you sample?
If you are on Solaris, use /usr/xpg4/bin/sh and /usr/xpg4/bin/awk instead of /bin/sh and awk
Last edited by Scrutinizer; 03-13-2012 at 05:34 PM..
I have this fileA
TEST FILE ABC
this file contains ABC;
TEST FILE DGHT this file contains DGHT;
TEST FILE 123
this file contains ABC,
this file contains DEF,
this file contains XYZ,
this file contains KLM
;
I want to have a fileZ that has only (begin search pattern for will be... (2 Replies)
Sorry if this is a super simple issue, but am extremely new to this and am trying to teach myself as I go along. But can someone please help me out?
I have a data file similar to this for many samples, for all chromosomes
Sample Chr bp p roh
Sample1 1 49598178 0 1... (14 Replies)
Hi All,
I am new to AWK programming. I have the following for loop in my awk program.
cat printhtml.awk:
BEGIN
-------- <some code here>
END{
----------<some code here>
for(N=0; N<H; N++)
{
for(M=5; M<D; M++) print "\t" D "";
}
-----
}
... (2 Replies)
Hello Guyz
I have been following this forum for a while and the solutions provided are super useful. I currently have a scenario where i need to search for a pattern and start searching by keeping the first pattern as a baseline
ABC
DEF
LMN
EFG
HIJ
LMN
OPQ
In the above text i need to... (8 Replies)
Hello All,
Im a Hardware engineer, I have written this script to automate my job. I got stuck in the following location.
CODE:
..
..
...
foreach $key(keys %arr_hash) {
my ($loc,$ind,$add) = split /,/, $arr_hash{$key};
&create_verilog($key, $loc, $ind ,$add);
}
sub create_verilog{... (2 Replies)
I am not able to read inside a while though i get the message "inside read" the cursor doesnt prompt from the console
cat file | while read ln_new_engine_dirs
do
echo "inside $ln_new_engine_dirs"
if
then
read nn
echo "inside read"
fi
done
Thanks in advance (3 Replies)
I am trying to pass a regular expression variable from a simple script to sed
to remove entries from a text file
e.g.
a='aaaa bbbb cccc ...|...:'
then executing sed from the script
sed s'/"'$a"'//g <$FILE > $FILE"_"1
my output file is always the same as the input file !!
any... (5 Replies)