Sponsored Content
Top Forums Shell Programming and Scripting Bash append values if keywords are present in the file Post 302994252 by venkitesh on Tuesday 21st of March 2017 03:03:37 AM
Old 03-21-2017
Hi Ravinder,

Thanks for your reply.

But this solution wont help for me.

as i mentioned in the question, there are six keywors present in this examplle (Gateway, Hostname, IP_Address,Netmask,Primary_DNS,Seconday_DNS). sometimes user may fill only 4 fileds then there will be only four keywors present in test. what i am looking for is if the keyword gateway is present anywhere in the file then append Gateway=3.3.3.3 in test1. like that for all keywords. if some keywords are not present it wont append anything

Kindly help
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Count Number Of lines in text files and append values to beginning of file

Hello, I have 50 text files in a directory called "AllFiles" I want to make a program that will go inside of the "AllFiles" Directory and count the number of lines in each individual text file. Then, the program will calculate how many more lines there are over 400 in each text file and... (7 Replies)
Discussion started by: motoxeryz125
7 Replies

2. Shell Programming and Scripting

Use sed to append text to filenames if text not already present

I have some html with hrefs that contain local links to pdf filenames. These filenames should have standardised names, i.e. there should be a label prior to the ".pdf" filename suffix. There can be many of these links on a single line of text and some may already have the label. For example ... (13 Replies)
Discussion started by: adb
13 Replies

3. UNIX for Dummies Questions & Answers

Passing values from file into array in Bash

Hi, I'm trying to write a bash script that takes a file and passes each line from the file into an array with elements separated by column. For example: Sample file "file1.txt": 1 name1 a first 2 name2 b second 3 name3 c third and have arrays such as: line1 = ( "1" "name1" "a"... (3 Replies)
Discussion started by: ShiGua
3 Replies

4. Shell Programming and Scripting

Find keywords, and append at the end of line

Task: Find keywords in each line, and append at the end of line; if not found in the line, do nothing. the code is wrong. how to make it work. thanks a lot. cat keywords.txt | while read line; do awk -F"|" '{if (/$line/) {print $0"$line , ";} else print;}' outfile.txt > tmp ... (9 Replies)
Discussion started by: dtdt
9 Replies

5. Shell Programming and Scripting

Match value in column and append file with new values

Hi, I need help to match two files based on two columns. file_1 ID AA An Ca Ele Pro Su Ot Tra g13950 No No Yes No Yes Yes Yes Yes g05760 Yes No No No No Yes Yes Yes g12640 No No No No No No No No k17720 No Yes No No No No No Yes g05640 Yes Yes Yes No No Yes Yes Yes file_2 ... (8 Replies)
Discussion started by: redse171
8 Replies

6. Shell Programming and Scripting

Unzip all the files with subdirectories present and append a part of string from the main .zip files

Hi frnds, My requirement is I have a zip file with name say eg: test_ABC_UH_ccde2a_awdeaea_20150422.zip within that there are subdirectories on each directory we again have .zip files and in that we have files like mama20150422.gz and so on. Iam in need of a bash script so that it unzips... (0 Replies)
Discussion started by: Ravi Kishore
0 Replies

7. Shell Programming and Scripting

Search files in directory for keywords using bash

I have ~100 text files in a directory that I am trying to parse and output to a new file. I am looking for the words chr,start,stop,ref,alt in each of the files. Those fields should appear somewhere in those files. The first two fields of each new set of rows is also printed. Since this is on a... (7 Replies)
Discussion started by: cmccabe
7 Replies

8. Shell Programming and Scripting

Ftp with bash, append file where left off

I'm working on a bash script to finish uploading a file. I need a way to get $filesize so that "restart $filesize" will work. Here is my script: ftp -n -v <<END_SCRIPT open ftp.$domain user $user@$domain $password size $file restart $filesize put $file quit END_SCRIPTWayne Sallee... (9 Replies)
Discussion started by: WayneSallee
9 Replies

9. UNIX for Beginners Questions & Answers

UNIX script to append multiple text files into one file based on pattern present in filaname

Hi All-I am new to Unix , I need to write a script. Can someone help me with a requirement where I have list of files in a directory, I want to Merge the files if a pattern of string matches in filenames? AAAL_555A_ORANGE1_F190404.TXT AAAL_555A_ORANGE2_F190404.TXT AAAL_555A_ORANGE3_F190404.TXT... (6 Replies)
Discussion started by: Shankar455
6 Replies

10. UNIX for Beginners Questions & Answers

Bash to append array value to file before copying

The bash stores each uniqueid in an array and then passes them to %q to get the unique path. That seems to work what I am having trouble with is renaming each .png with the unique value in %q. I thought it was working but upon closer inspection, a .png file is being sent to scp.... but only 1 and... (21 Replies)
Discussion started by: cmccabe
21 Replies
ECACCESS-ASSOCIATION-GET(1p)				User Contributed Perl Documentation			      ECACCESS-ASSOCIATION-GET(1p)

NAME
ecaccess-association-get - Get the Association Descriptive File SYNOPSIS
ecaccess-association-get -version|-help|-manual ecaccess-association-get [-debug] [-gateway name] [-template] association-name target-file DESCRIPTION
Get the Descriptive File for the ECtrans Association specified by the association-name parameter. Once downloaded, the target-file can be modified and processed through the ecaccess-association-put command. When using the -template option, if the Association already exists in the ECaccess Gateway Database, then the command return with an error. In order to create a new Association similar to an existing one the ecaccess-association-get command can be used to retrieve the Descriptive File of the existing Association. The file can then be updated and pushed to the ECaccess Gateway Database with the ecaccess- association-put command. An ECtrans Association Descriptive File contains parameters for ECtrans of the general form $name='value'. Each ECtrans Association has their own Descriptive File, and parameters in any given Descriptive File will be passed to the ECtrans container whenever a transfer is requested to the corresponding Association. Blank lines and leading spaces and tabs are ignored when they do not occur in single quoted strings. Lines whose first non-space character is a pound-sign (#) are comments, and are ignored. Note that comments are not allowed on the same line as parameters and don't persist when the Descriptive File is retrieved from the Gateway (they might however be used when Descriptive Files are archived on your system). The parameters are the following: active This is a boolean which indicate if the Association can be used by ECtrans or not (e.g. 'yes' or 'no'). You might want to deactivate an Association but still keep it in the ECaccess Gateway Database for later. comment This is a comment about your Association (e.g. 'Access to the archive system'). grantedUserList This is the list of ECMWF user identifiers which are allowed (other that you) to use this Association. Multiple users should be separated by a column (e.g. 'abc,def,ghi'). directory This is the directory where to download/upload the files from/to (e.g. '/tmp/data'). hostName This is the name of the host to connect to (e.g. 'hostname.example.ms'). login This is the login to use to connect to the host specified in the hostName parameter (e.g. 'anonymous'). protocol This is the protocol ECtrans will use to connect to the host specified in the hostName parameter. The list of available protocols for a Gateway can be displayed with the ecaccess-protocol-list command (e.g. 'genericFtp'). data This parameter can be split over multiple lines and contains various options for the protocol which have been selected for the Association (these options are passed verbatim to the Module which implement the protocol). In order to get the list of available options for a protocol please use the command ecaccess-association-protocol with the name of the protocol. The availabe options depends of the version of the ECaccess Gateway which is used to host the Association so it might be that some options are available for some Gateways and not available for others. An unknown option will be silently ignored by ECtrans. The format of an option is {protocol-shortname}.{option}={value} (e.g. ftp.port="21" would set the port option of the genericFtp module to "21"). An example of this parameter is given in the EXAMPLES section below. ARGUMENTS
association-name The name of the Association to retrieve the corresponding Descriptive File. target-file The name of the file where to download the Descriptive File. OPTIONS
-gateway name This is the name of the ECaccess Gateway where the Association is installed. It is by default the Gateway you are connected to. In order to get the name of your current Gateway you can use the ecaccess-gateway-name command. When using the commands at ECMWF the default Gateway is always "ecaccess.ecmwf.int". -template Allow creating a new Association Descriptive File for the ecaccess-association-put command. If the Association already exists then the command fails. -version Display version number and exits. -help Print a brief help message and exits. -manual Prints the manual page and exits. -debug Display the SOAP messages exchanged. EXAMPLES
ecaccess-association-get -template test ./test Create a new Association Descriptive File for an Association named test and store it in your current directory (file ./test). The file can then be edited and updated accordingly to your requirements. ecaccess-association-put -password ./test Create the Association with the previously updated ./test Association Descriptive File. ecaccess-association-get -gateway ecaccess.ecmwf.int ginko ./ginko Get the Descriptive File for the existing ginko Association on the ecaccess.ecmwf.int Gateway. ecaccess-association-put -gateway ecaccess.ecmwf.int ./ginko Push the Association back (once updated). This is an example of an Association Descriptive File: ############################################################## # Main Parameters ############################################################## $active='yes' $comment='Access to the archive system' $grantedUserList='abc,def,jhi' $directory='/tmp/data' $hostName='hostname.example.ms' $login='anonymous' $protocol='genericFtp' ############################################################## # Data ############################################################## $data=' ftp.mkdirs="yes" ftp.passive="no" ftp.port="21" ftp.suffix=".tmp" ftp.usetmp="yes"' Please note the multiple lines in the data parameter. SEE ALSO
ecaccess-association-delete, ecaccess-association-list, ecaccess-association-protocol, ecaccess-association-put and ecaccess. perl v5.14.2 2012-04-16 ECACCESS-ASSOCIATION-GET(1p)
All times are GMT -4. The time now is 06:39 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy