Sponsored Content
Full Discussion: Replacement Query in a file
Top Forums Shell Programming and Scripting Replacement Query in a file Post 302985923 by mad_man12 on Thursday 17th of November 2016 04:14:06 AM
Old 11-17-2016
Replacement Query in a file

Hi All,
Please can you help me with below, i have a file with records ( eg of one record below)
Record R1 - The field separtaor between records is | (Pipe)
Code:
 |123|Mukesh\r\n|Vivek"sharma|


Now i want to do the following for each record in the file
if there is any field ( lets say field is F1) in the record having \r\n ( carriage return and new line coming together ) or single quotes i have to do the following
Replace single quotes with Double quotes
and put the entire field in opening and closing double quotes like this "F1"
so the output should be like for record R1

Code:
|123|"Mukesh\r\n"|"Vivek""sharma"|




Moderator's Comments:
Mod Comment Please use CODE tags as required by forum rules!
Enclosing the ENTIRE post in CODE tags isn't the right way either!

Last edited by RudiC; 11-17-2016 at 06:01 AM.. Reason: Changed CODE tags' positions.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

finding a numeric value in a file for replacement

thank u optimus,but one more dout..it might be silly..how do i get the value in the file that should be replaced..while running the script..its an numeric value..that i want to change.. when i used sed for replacement ie. sed s/521000/100/p with print option it is printing... (4 Replies)
Discussion started by: Babu
4 Replies

2. Shell Programming and Scripting

Replacement of text in a file

Hi , I have some data in my file(properties.txt) like this. # agent.properties agent.dmp.Location= agent.name= I need to relpace the agent.dmp.location with agent.dmp.Location = /opt/VRTS/vxvm I am using the follwing to replace the string AGENT_NAME=snmp... (2 Replies)
Discussion started by: raghu.amilineni
2 Replies

3. Shell Programming and Scripting

sed replacement in unicode file

Hi there, I have a file generated by a windows registry (it's unicode) and can't get to do some replacements on it. I want to join lines that end with backslash with the next one. santiago@ks354286:~$ cat win.reg ÿþWindows Registry Editor Version 5.00 ... (10 Replies)
Discussion started by: chebarbudo
10 Replies

4. Shell Programming and Scripting

Shell Script to execute Oracle query taking input from a file to form query

Hi, I need to query Oracle database for 100 users. I have these 100 users in a file. I need a shell script which would read this User file (one user at a time) & query database. For instance: USER CITY --------- ---------- A CITY_A B CITY_B C ... (2 Replies)
Discussion started by: DevendraG
2 Replies

5. Shell Programming and Scripting

File Replacement Help

Hi all, I have two files, one is a base file and the other is a dependency file. I need to replace a section in the base file (File A) with a section from the dependency file (File B), for example: File A: ... <TagName> <TagA>MyBaseFile</TagA> <TagB>MyBaseFileID</TagB> </TagName>... (5 Replies)
Discussion started by: muay_tb
5 Replies

6. Shell Programming and Scripting

Unix file pattern check and replacement

HI Guys , Using UNIX ,I intend to check with correct file pattern Access_file_Record.YYYYMM in path /tmp If the file exist in correct format come out from code . If not found check with different file patterns for same month period YYYYMM ( Like Access_file_Record_YYYYMM.txt or... (8 Replies)
Discussion started by: Perlbaby
8 Replies

7. Shell Programming and Scripting

Conditional replacement of columns in a text file

Hello scriping expert friends, I have 2 requirements on replacing fields of text files: I have lot of data with contents like below: Requirement-1: The digit after 0 should always be changed to 1 (3 Replies)
Discussion started by: magnus29
3 Replies

8. UNIX for Dummies Questions & Answers

File size changes on replacement of certain numbers

I had a doubt regarding how the file size changes and needed some advice on the same So I have this file say abc.txt.. Size was 10000. Now inside the file when I go and I replace all the number 7 numerals with number 4 file size changed to 9984. Any idea why and how ?? (8 Replies)
Discussion started by: sidnow
8 Replies

9. Shell Programming and Scripting

Sed: how to use file contents in replacement string

I want to replace a string by contents of file. I am trying the following sed command: cat sample | sed "s^<enter description here>^`cat details`^" But it is not working. a=`cat details` and using $a will not help since it will affect the whitespaces. What am I missing in the above sed... (5 Replies)
Discussion started by: anand_bh
5 Replies

10. Shell Programming and Scripting

Replacement of variable by their content in a file

Dear all, I have a "SQL request" in a file: that request include different "host variable" and I would like to substitute the different "host variable" by their respective content before executing the request. For example: $ echo $SHELL /bin/bash $ cat dae2.txt DELETE FROM ... (11 Replies)
Discussion started by: dae
11 Replies
Jifty::DBI::Record::Memcached(3pm)			User Contributed Perl Documentation			Jifty::DBI::Record::Memcached(3pm)

NAME
Jifty::DBI::Record::Memcached - records with caching behavior SYNOPSIS
package Myrecord; use base qw/Jifty::DBI::Record::Memcached/; DESCRIPTION
This module subclasses the main Jifty::DBI::Record package to add a caching layer. The public interface remains the same, except that records which have been loaded in the last few seconds may be reused by subsequent get or load methods without retrieving them from the database. METHODS
load_from_hash Overrides the implementation from Jifty::DBI::Record to add support for caching. load_by_cols Overrides the implementation from Jifty::DBI::Record to add support for caching. _cache_config You can override this method to change the duration of the caching from the default of 5 seconds. For example, to cache records for up to 30 seconds, add the following method to your class: sub _cache_config { { 'cache_for_sec' => 30 } } memcached_config Returns a hash containing arguments to pass to Cache::Memcached during construction. The defaults are like: ( services => [ '127.0.0.1:11211' ], debug => 0, ) You may want to override this method if you want a customized cache configuration: sub memcached_config { ( servers => [ '10.0.0.15:11211', '10.0.0.15:11212', '10.0.0.17:11211', [ '10.0.0.17:11211', 3 ] ], debug => 0, compress_threshold => 10_000, ); } cache_key_prefix Returns the prefix we should prepend to all cache keys. If you're using one memcached for multiple applications, you want this to be different for each application or they might end up mingling data. AUTHOR
Matt Knopp <mhat@netlag.com> SEE ALSO
Jifty::DBI, Jifty::DBI::Record perl v5.14.2 2010-09-21 Jifty::DBI::Record::Memcached(3pm)
All times are GMT -4. The time now is 03:25 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy