Sponsored Content
Full Discussion: replacing a character
Top Forums UNIX for Dummies Questions & Answers replacing a character Post 302300056 by vino on Monday 23rd of March 2009 05:21:10 AM
Old 03-23-2009
Quote:
Originally Posted by Usha Shastri
Hi All,

contents of my file is like this:

xxx xxx1 N N N 0
yyy yyy1 Y N N 0

i want to replace 1st N of xxx xxx1 N N N 0 line with Y.
i. e i want the output like this:
xxx xxx1 Y N N 0

how can i do this?
please help.
Thanks
Here is one way to do it

Code:
sed -e "s/xxx xxx1 N/xxx xxx1 Y/g" input.txt

If you want to generalize it, you need to show us a little bit more of the input.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Replacing the last character

Hi , I need to change the last character of the line: ie: input file: (raj, muthu, mani, Output: (raj, muthu, mani); so i need to change the last comma by the closing braces so help me out in the issue. Thanks in advance. (2 Replies)
Discussion started by: ithirak17
2 Replies

2. Linux

replacing enter character in LINUX

Hi 1) I need to replace an "enter" character with another character. I thought it should be like this (E.G) replace all stirngs "LIAV"+enter with kokokoko: :1,$s/LIAV^M/kokokoko/g but it dose not work. 2) Also dose nayone know how to replace wildcards? for... (3 Replies)
Discussion started by: liav
3 Replies

3. Shell Programming and Scripting

replacing a character with another

hi i have a file and reading line by line, i need to replace 8-15 and 18-27 charaters with character 'x'. Eg: satyasatxxxxxxxsatxxxxxxxxxtyasatyasatyasatyasatyasatya please help thanks Satya (1 Reply)
Discussion started by: Satyak
1 Replies

4. UNIX for Dummies Questions & Answers

replacing 1 character with many : tr

Hi All, I would like to know how, iff at all we can, we may use the 'tr' command to replace a single character with multiple characters. eg: if i have a string valued "him", how can i use 'tr' to replace 'i' with "oo" to make "hoom". Just replacing a single character by many. tried:-... (16 Replies)
Discussion started by: hkansal
16 Replies

5. UNIX for Dummies Questions & Answers

Replacing a character in a line

Hi All I want to replace a character in a line, but position will be different form one iteration to another. So i m keeping the position i a variable. I am trying with following code pos=3 echo "Hello World, Good Morning" | sed 's/\(.\{$pos\}\)./\1Y/' But its not working, Can you... (2 Replies)
Discussion started by: Usha Shastri
2 Replies

6. Shell Programming and Scripting

Replacing the last character for each line in a file

Hello, I have a csv file and will like to replace the last character of each line in the file with Z (20 Replies)
Discussion started by: 123script
20 Replies

7. Shell Programming and Scripting

Replacing the new character with spaces

Hi Experts, We are facing some while loading the "csv" file to target table.Some of the records are having values as : Account number,Name,Address "123","XYZ","302 Street,Washington,US" "456","PQR"," 3233 Some Street, Washington,US" In the above file instead reading only two records it... (11 Replies)
Discussion started by: Amey Joshi
11 Replies

8. Shell Programming and Scripting

replacing by newline character

I have a file (pema)with a single long record which i have to break up into multiple lines Input s1aaaaaaaaaaaaaaaaaaaaaaas1bbbbbbbbbbs1cccccccccc Output s1aaaaaaaaaaaaaaaaaaaaaaa s1bbbbbbbbbb s1cccccccccc m planning to do it by replacing s1 by \ns1 \n is the new line character i... (5 Replies)
Discussion started by: pema.yozer
5 Replies

9. Shell Programming and Scripting

Replacing a character between two numbers

Hi, I need to replace a character between two numbers (specifically a - to a _). The problem is that they can be *any* numbers. So, I need a one liner to turn a file like this: 1-2 3-4 55-66 4323-12312893 into the following 1_2 3_4 55_66 4323_12312893 Any help would be appreciated! (5 Replies)
Discussion started by: mikey11415
5 Replies

10. UNIX for Dummies Questions & Answers

Replacing special character with sed

Hi All, I have a text file that contains I1SP2 *=*=Y=M=D001D My requirement is to replace all occurrence of =* to =Z expected o/p is I1SP2 *=Z=Y=M=D001D I have tried with sed 's/=*/=Z/g' file sed 's!\=*!\=Z/g' file sed 's!\=*!\=Z!g' file sed 's!\=\*!\=Z!g' file but its not... (3 Replies)
Discussion started by: gotamp
3 Replies
LWP::Authen::OAuth(3pm) 				User Contributed Perl Documentation				   LWP::Authen::OAuth(3pm)

NAME
LWP::Authen::OAuth - generate signed OAuth requests SYNOPSIS
require LWP::Authen::OAuth; Google # Google uses 'anonymous' for unregistered Web/offline applications or the # domain name for registered Web applications my $ua = LWP::Authen::OAuth->new( oauth_consumer_secret => "anonymous", ); # request a 'request' token my $r = $ua->post( "https://www.google.com/accounts/OAuthGetRequestToken", [ oauth_consumer_key => 'anonymous', oauth_callback => 'http://example.net/oauth', xoauth_displayname => 'Example Application', scope => 'https://docs.google.com/feeds/', ] ); die $r->as_string if $r->is_error; # update the token secret from the HTTP response $ua->oauth_update_from_response( $r ); # open a browser for the user # data are returned as form-encoded my $uri = URI->new( 'http:' ); $uri->query( $r->content ); my %oauth_data = $uri->query_form; # Direct the user to here to grant you access: # https://www.google.com/accounts/OAuthAuthorizeToken? # oauth_token=$oauth_data{oauth_token} "; # turn the 'request' token into an 'access' token with the verifier # returned by google $r = $ua->post( "https://www.google.com/accounts/OAuthGetAccessToken", [ oauth_consumer_key => 'anonymous', oauth_token => $oauth_data{oauth_token}, oauth_verifier => $oauth_verifier, ]); # update the token secret from the HTTP response $ua->oauth_update_from_response( $r ); # now use the $ua to perform whatever actions you want Twitter Sending status updates to a single account is quite easy if you create an application. The "oauth_consumer_key" and "oauth_consumer_secret" come from the 'Application Details' page and the "oauth_token" and "oauth_token_secret" from the 'My Access Token' page. my $ua = LWP::Authen::OAuth->new( oauth_consumer_key => 'xxx1', oauth_consumer_secret => 'xxx2', oauth_token => 'yyy1', oauth_token_secret => 'yyy2', ); $ua->post( 'http://api.twitter.com/1/statuses/update.json', [ status => 'Posted this using LWP::Authen::OAuth!' ]); DESCRIPTION
This module provides a sub-class of LWP::UserAgent that generates OAuth 1.0 signed requests. You should familiarise yourself with OAuth at <http://oauth.net/>. This module only supports HMAC_SHA1 signing. OAuth nonces are generated using the Perl random number generator. To set a nonce manually define 'oauth_nonce' in your requests via a CGI parameter or the Authorization header - see the OAuth documentation. METHODS
$ua = LWP::Authen::OAuth->new( ... ) Takes the same options as "new" in LWP::UserAgent plus optionally: oauth_consumer_key oauth_consumer_secret oauth_token oauth_token_secret Most services will require some or all of these to be set even if it's just 'anonymous'. $ua->oauth_update_from_response( $r ) Update the "oauth_token" and "oauth_token_secret" from an HTTP::Response object returned by a previous request e.g. when converting a request token into an access token. $key = $ua->oauth_consumer_key( [ KEY ] ) Get and optionally set the consumer key. $secret = $ua->oauth_consumer_secret( [ SECRET ] ) Get and optionally set the consumer secret. $token = $ua->oauth_token( [ TOKEN ] ) Get and optionally set the oauth token. $secret = $ua->oauth_token_secret( [ SECRET ] ) Get and optionally set the oauth token secret. SEE ALSO
LWP::UserAgent, MIME::Base64, Digest::SHA, URI, URI::Escape Rationale I think the complexity in OAuth is in the parameter normalisation and message signing. What this module does is to hide that complexity without replicating the higher-level protocol chatter. In Net::OAuth: $r = Net::OAuth->request('request token')->new( consumer_key => 'xxx', request_url => 'https://photos.example.net/request_token', callback => 'http://printer.example.com/request_token_ready', ... extra_params { scope => 'global', } ); $r->sign; $res = $ua->request(POST $r->to_url); $res = Net::OAuth->response('request token') ->from_post_body($res->content); ... etc In LWP::Authen::OAuth: $ua = LWP::Authen::OAuth->new( oauth_consumer_key => 'xxx' ); $res = $ua->post( 'https://photos.example.net/request_token', [ oauth_callback => 'http://printer.example.com/request_token_ready', ... scope => 'global', ]); $ua->oauth_update_from_response( $res ); ... etc Net::OAuth, OAuth::Lite. AUTHOR
Timothy D Brody <tdb2@ecs.soton.ac.uk> Copyright 2011 University of Southampton, UK This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself perl v5.12.3 2011-03-31 LWP::Authen::OAuth(3pm)
All times are GMT -4. The time now is 04:09 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy