Sponsored Content
Top Forums Shell Programming and Scripting Substitute variable inside nawk Post 302903498 by mohtashims on Wednesday 28th of May 2014 05:26:01 AM
Old 05-28-2014
Hammer & Screwdriver

Let me rephrase my question.

I am using the below code to find the difference between two files prod.properties and back.properties.

Code:
nawk '/^#/ {next} NR==FNR {prod[$0]=$0;next} {if ($0 in prod) { delete prod[$0] } else {print }}; END {for (i in prod) print prod[i]}' prod.properties back.properties

Source: https://www.unix.com/302903183-post5.html

Now, the requirement is to automate the above code so that it does the job for any two file names not neccessarily prod.properties and back.properties

I am passing any two filenames like this.

Code:
./check.sh filename1.properties filename2.txt

and reading them in variables file1=$1, file2=$2.

So, how can I achieve that ?
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Substitute variable values

Hi, I am trying to redefine the value of a variable based on another variable value. And I want to read in my variables from a enviroment file in the end -- at least I think so. But 1st here's what I want I need to get working: var_1="11 10 9 8 7 6 5 4 3 2 1" var_2=3 var_3=4 So I want... (12 Replies)
Discussion started by: John Rihn
12 Replies

2. UNIX for Dummies Questions & Answers

Substitute Variable

Can anyone tell me what is the purpose of a substitute variable in the unix programming language and give an example where it may be used? Thanks! (0 Replies)
Discussion started by: mmg2711
0 Replies

3. Shell Programming and Scripting

case command inside awk/nawk

well I found lot of topics about awk..about if command in awk.. but I had to implement this: nawk -F"|" ' $47 ~ /0R0011/ { print > ("/home/user/M/MC.tmp" )} $47 ~ /0R0012/ { print > ("/home/user/M/DuSI.tmp" )} $47 ~ /0R0014/ { print > ("/home/user/M/FF.tmp" )} $47 ~ /0R0018/ { print >... (9 Replies)
Discussion started by: abdulaziz
9 Replies

4. Shell Programming and Scripting

using cp command inside nawk

Hello I have facing issue while using cp command inside nawk block. #!/bin/ksh my_name=$1 nawk -v my_name1=$my_name 'BEGIN { n = split(my_name1,names,":"); for (i=1;i<=n;i++) { print names; cpcmd = "cp " /tmp/test.txt" " ./sample system(cpcmd) } exit }' exit 0 i'am getting... (1 Reply)
Discussion started by: piscean_n
1 Replies

5. Shell Programming and Scripting

variable inside variable inside loop headache

Hi Gurus I have a file called /tmp/CMDB which looks like this serial: 0623AN1208 hostname: server1 model: x4100 assetID: 1234 I am writing a for loop that will go through this file line by line creating a variable of itself. Using the first iteration of the loop (i.e. the first line) as... (6 Replies)
Discussion started by: hcclnoodles
6 Replies

6. Shell Programming and Scripting

substitute variable for values in perl

hi all, how do i assign values passed in from command line to and sql statement in perl ?? e.g i want to assign :name1 and :Name2 to be whatever is passed into the perl script command line my $sqlStr = "select * from test_table where column1 = upper(nvl(:name1, name1 )) and column2... (1 Reply)
Discussion started by: cesarNZ
1 Replies

7. Shell Programming and Scripting

substitute variable in bash

hi all, Assume that i a having the following three lines in an executable file #/bin/bash a=Tue Tue=1 When i give echo $a the value should be 1, how to do this. Your suggestions please. Thanks in advance, Anish (4 Replies)
Discussion started by: anishkumarv
4 Replies

8. Shell Programming and Scripting

Reading input record from inside nawk

Hi friends, I have small query with reg to awk search pattern.. below is my sample file and code which i tried.. $ cat file.txt xxx,yyyyy,messageID,sha xxxx,errorcode,messageID,name in the above sample file - let assume I know the errorcode(2nd record) using which I want to... (2 Replies)
Discussion started by: Shahul
2 Replies

9. Shell Programming and Scripting

AWK variable substitute issue

dear, I have below file called folderlist.txt # ParentFolder environment_flag SubFolders triss 1 checksum bookstructure 1 fx 1 checksum_GMDB I have a script which which will create the folders under... (3 Replies)
Discussion started by: manas_ranjan
3 Replies

10. UNIX for Beginners Questions & Answers

How to avoid arguments inside Nawk command?

Hi, Here is my command print $2 was meant to select the second column however, it is getting substituted with the second argument that was passed to the script. Can you please tell me how can I resolve this ? (6 Replies)
Discussion started by: mohtashims
6 Replies
gnome-display-properties(1)					   User Commands				       gnome-display-properties(1)

NAME
gnome-display-properties - customize GNOME display behavior SYNOPSIS
gnome-display-properties [gnome-std-options] DESCRIPTION
The GNOME display preference tool enables you to customize the screen resolution and refresh rate for your desktop. OPTIONS
The following options are supported: gnome-std-options Standard options available for use with most GNOME applications. See gnome-std-options(5) for more information. EXAMPLES
Example 1: Launching the gnome-display-properties tool example% gnome-display-properties EXIT STATUS
The following exit values are returned: 0 Application exited successfully >0 Application exited with failure FILES
The following files are used by this application: /usr/bin/gnome-display-properties Executable for gnome-display-properties ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWgnome-desktop-prefs | +-----------------------------+-----------------------------+ |Interface stability |Volatile | +-----------------------------+-----------------------------+ SEE ALSO
Preference Tools Manual Latest version of the GNOME Desktop User Guide for your platform. gnome-control-center(1), attributes(5), gnome-std-options(5) NOTES
Written by Brian Cameron, Sun Microsystems Inc., 2007. SunOS 5.11 09 Nov 2007 gnome-display-properties(1)
All times are GMT -4. The time now is 11:32 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy