Search Results

Search: Posts Made By: Rajesh_us
1,470
Posted By shamrock
That is correct...you cant embed variables in a...
That is correct...you cant embed variables in a /regexp/...
1,470
Posted By vgersh99
if you know it's checking the 3-rd field, you...
if you know it's checking the 3-rd field, you should be able to adjust it for 'anywhere'....

awk -v a='000' '$0 ~ a' file1.txt
1,470
Posted By vgersh99
I don't follow. What's wrong with the solution?
I don't follow. What's wrong with the solution?
1,470
Posted By vgersh99
awk -v a='000' '$3 ~ a' file1.txt
awk -v a='000' '$3 ~ a' file1.txt
2,007
Posted By jlliagre
You are missing an option: #!/bin/ksh set -x ...
You are missing an option:
#!/bin/ksh
set -x
n=1
a=45
echo "1,2,3,4"|awk -F "," -v a=$a -v n=$n 'NR==n{$3=a}1' OFS=","
2,007
Posted By jlliagre
Because you reformatted the output by modifying a...
Because you reformatted the output by modifying a field, just set the print output separator to the one you want:

$ echo "1,2,3,4"|nawk -F "," 'NR==n{$3=a}1' n=1 a=45 OFS=","
1,2,45,4
7,244
Posted By Don Cragun
I have been fighting a losing battle with the...
I have been fighting a losing battle with the flu. I didn't realize it had affected my ability to read and write code. Please accept my humble apologies.

The arguments to Chubler_XL's rot()...
7,244
Posted By Don Cragun
In Chubler_XL's function rot(), change the line: ...
In Chubler_XL's function rot(), change the line:
for(i=start;i<=length(string);i++) {to:
for(i=length(string);i;i--) {
7,244
Posted By Don Cragun
I would have thought this would be obvious by...
I would have thought this would be obvious by now, but:
$5=rot($5)
replaces the 5th field with every alphanumeric character (starting at the beginning of the field through the end of the field)...
7,244
Posted By Chubler_XL
Like this: k3=17 awk -F\* -v k3="$k3" ' ...
Like this:

k3=17
awk -F\* -v k3="$k3" '
...
NR == k3 { $5=rot($5) } 1 ' $file

or this

k3='NM1\\*IL\\*1*'
awk -F\* -v k3="$k3" '
...
$0 ~ k3 { $5=rot($5,1,4) } 1' $file
7,244
Posted By Chubler_XL
Looks like some more flexibility in the code...
Looks like some more flexibility in the code could help you change things to get what you require.

Start with this for example 2 (Change all of field 5):

awk -F\* '
function...
7,244
Posted By Don Cragun
You have changed your requirements so many times...
You have changed your requirements so many times that I have absolutely no idea what you want to do. Please give us a complete set of requirements.

Are we processing a single line in a file or...
7,244
Posted By Chubler_XL
This should match on field three, notice how if...
This should match on field three, notice how if matching the "*" (star) character two backquotes are needed.

The star on the end is to match with the rest of the string so example is looking for...
7,244
Posted By Akshay Hegde
@ Don You are right as always ! I tested...
@ Don

You are right as always ! I tested it on GNU Awk 3.1.7, without warnings it worked there.
7,244
Posted By Don Cragun
I'm not concerned about your English. You are...
I'm not concerned about your English. You are much better at English than I am in your native language! (When I attended college, I was allowed to use proficiency in FORTRAN and CDC assembler to...
7,244
Posted By Akshay Hegde
Don I don't know about the OS/X, and in second...
Don I don't know about the OS/X, and in second example I mean to say retain 1st five char and 5th char onwards to length of line replace with some string, Sorry for bad English
7,244
Posted By Don Cragun
Note that the standards say that the results are...
Note that the standards say that the results are unspecified if an empty string is assigned to FS. Some versions of awk will produce the output you showed above in your first example. The version...
7,244
Posted By Don Cragun
So there were two off by one errors. Also...
So there were two off by one errors. Also change:
for(i=1;i<length(F);i++)N[substr(F,i,1)]=substr(T,i,1);to:
for(i=1;i<=length(F);i++)N[substr(F,i,1)]=substr(T,i,1);
7,244
Posted By Don Cragun
Many versions of awk limit the length of a line...
Many versions of awk limit the length of a line to LINE_MAX bytes. The value of LINE_MAX on your system can be found using getconf LINE_MAX). But it looks like there is an off by one error that is...
7,244
Posted By Chubler_XL
Yes found that Issue and corrected the posted...
Yes found that Issue and corrected the posted code - please try again
7,244
Posted By vgersh99
not quite sure what 'you want or any other...
not quite sure what 'you want or any other suggestion' - Don's explanation seems to be clear to me explaining what you're getting.
If for example, you want to change A to Z, but if there was a...
7,244
Posted By Chubler_XL
How about this: awk ' BEGIN{ ...
How about this:

awk '
BEGIN{
F="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
T="ZYXWVUTSRQPONMLKJIHGFEDCBAzyxwvutsrqponmlkjihgfedcba9876543210"
...
7,244
Posted By Don Cragun
Maybe you didn't realize that if you change all...
Maybe you didn't realize that if you change all occurrences of A to Z and then change all occurrences of Z to A, everything that was an A or a Z in the original input will be an A in the output. The...
1,489
Posted By Don Cragun
See what happens if N1 had been set using...
See what happens if N1 had been set using N1='$(echo *)' when you run that eval command.

Then imagine what would happen if a malicious user changed echo to rm -rf when he/she provided the value to...
1,489
Posted By CarloM
What are you actually trying to do? Use the value...
What are you actually trying to do? Use the value of N1 as part of the variable name?

If you're on bash, you could do something like:
$ N1=1
$ a1=18
$ varname="a${N1}"
$ f1=${!varname}
$ echo...
Showing results 1 to 25 of 32

 
All times are GMT -4. The time now is 10:05 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy