Changing different value to single value


 
Thread Tools Search this Thread
# 1  
Changing different value to single value

I have a input file like this
Code:
select column1,column2 from tablename where column3='1000000001';
select column1,column2 from tablename where column3='1000000002';
select column1,column2 from tablename where column3='1000000003';
select column1,column2 from tablename where column3='1000000004';
select column1,column2 from tablename where column3='1000000005';

I need like this
Code:
select column1,column2 from tablename where column3='1100000001';
select column1,column2 from tablename where column3='1100000001';
select column1,column2 from tablename where column3='1100000001';
select column1,column2 from tablename where column3='1100000001';
select column1,column2 from tablename where column3='1100000001';

Code:
My shell is csh

# 2  
Try

Code:
 
awk -F "'" '{$2=1100000001}1' OFS="'" file

This User Gave Thanks to pamu For This Post:
# 3  
Additionally how to handle this scenario
I have input file like this
Code:
update tablename set column1='ABC',column2='BBC' where columnx=1 and columny=100 and columnz='10000001'
update tablename set column1='ABC',column2='BBC',column3='CBC' where columnx=1 and columny=100 and columnz='10000002'
update tablename set column1='ABC' where columnx=1 and columny=100 and columnz='10000003'
update tablename set column1='ABC',column2='BBC',column3='EBC',column4='GBC' where columnx=1 and columny=100 and columnz='10000004'
update tablename set column1='ABC',column2='BBC',column3='FBC' where columnx=1 and columny=100 and columnz='10000005'

I need like this
Code:
update tablename set column1='ABC',column2='BBC' where columnx=1 and columny=100 and columnz='11000001'
update tablename set column1='ABC',column2='BBC',column3='CBC' where columnx=1 and columny=100 and columnz='11000001'
update tablename set column1='ABC' where columnx=1 and columny=100 and columnz='11000001'
update tablename set column1='ABC',column2='BBC',column3='EBC',column4='GBC' where columnx=1 and columny=100 and columnz='11000001'
update tablename set column1='ABC',column2='BBC',column3='FBC' where columnx=1 and columny=100 and columnz='11000001'

# 4  
Try

Code:
awk -F "'" '{$(NF-1)=11000001}1' OFS="'" file

This User Gave Thanks to pamu For This Post:
# 5  
Another way using sed.

Match any number of numbers between single quotes:
Code:
sed "s/'[0-9]*'/'1100000001'/" file

or match 10 numbers in a row:
Code:
sed 's/[0-9]\{10\}/1100000001/' file

This User Gave Thanks to gary_w For This Post:
 

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Changing single path NIC to a teamed connection in same subnet

Dear all, I have a remote CentOS7 server that has two network cards. Each card has four ports and port one of card one was defined with the IP address assigned to the server. So far, so good and it's been working for over a year. We have now got cables sorted out so there are four paths... (4 Replies)
Discussion started by: rbatte1
4 Replies

2. Shell Programming and Scripting

Paste 2 single column files to a single file

Hi, I have 2 csv/txt files with single columns. I am trying to merge them using paste, but its not working.. output3.csv: flowerbomb everlon-jewelry sofft steve-madden dolce-gabbana-watchoutput2.csv: http://www1.abc.com/cms/slp/2/Flowerbomb http://www1.abc.com/cms/slp/2/Everlon-Jewelry... (5 Replies)
Discussion started by: ajayakunuri
5 Replies

3. Shell Programming and Scripting

Multiple lines in a single column to be merged as a single line for a record

Hi, I have a requirement with, No~Dt~Notes 1~2011/08/1~"aaa bbb ccc ddd eee fff ggg hhh" Single column alone got splitted into multiple lines. I require the output as No~Dt~Notes 1~2011/08/1~"aaa<>bbb<>ccc<>ddd<>eee<>fff<>ggg<>hhh" mean to say those new lines to be... (1 Reply)
Discussion started by: Bhuvaneswari
1 Replies

4. Shell Programming and Scripting

Replace single quote with two single quotes in perl

Hi I want to replace single quote with two single quotes in a perl string. If the string is <It's Simpson's book> It should become <It''s Simpson''s book> (3 Replies)
Discussion started by: DushyantG
3 Replies

5. UNIX for Dummies Questions & Answers

Changing / to - with vi

Hi just learning Unix in college now and this is my first post here, so I dunno if this goes here, or in the homework section technically. Anywho, trying to change all the / in a file into - using vi... i went into the command prompt, and put in :%s///-/g and it comes up with E488: Trailing... (2 Replies)
Discussion started by: SoVi3t
2 Replies

6. Shell Programming and Scripting

unzip single file and untar single file

Dear friends, My requirement below- 1] I have a zip file on unix server - ETL_Extracts_20100218175009.zip which is composed of various entity extracts namely... ENTITY1.txt, ENTITY2.txt, ENTITY3.txt etc.... How do I unzip only a single file ..say ENTITY2.txt from this zip file. CAn you... (2 Replies)
Discussion started by: sureshg_sampat
2 Replies

7. Shell Programming and Scripting

Help with awk script, changing the FS for a single variable

Hi all, im new to awk and would apreciate if you could tell me how to do this, i have a file with several entries like this: 2008-09-09 21:57:45 44 403 CUSTOM_EVENT Upgrade - end1 2008-09-09 21:57:46 45 403 CUSTOM_EVENT Component Check - start... (3 Replies)
Discussion started by: sx3v1l_1n51de
3 Replies

8. Linux

changing date

Hi, I want to create one user who has right to change the date in linux, (1 Reply)
Discussion started by: manoj.solaris
1 Replies

9. UNIX for Dummies Questions & Answers

Changing owner???

How to change the owner of a file. example: suppose original owner is A and we want to change to B Please provide the syntax Thanks (1 Reply)
Discussion started by: skyineyes
1 Replies

10. Shell Programming and Scripting

Changing userID and Changing group and GID

Hello, I want to write a ksh script about changing UID and changing group with GID. There are multiple servers i want to perform that job. linux1 linux2 linux3 linux4 linux5 ...... . . . . . 1.) How can i enter "password" in script rather asking me? I was trying this... ssh... (2 Replies)
Discussion started by: deal732
2 Replies

Featured Tech Videos