Sponsored Content
Top Forums Shell Programming and Scripting Search for multiple string and replace with respective values Post 302502180 by zooby on Monday 7th of March 2011 06:19:19 AM
Old 03-07-2011
Thanks for your reply. My requirement is slightly different. Search for different set of string and replace with respective value with accurate field position. For example i want to search specific set of strings from 25 to 35 and repalce with corresponding values. If replacing value has 10 character then remaining 5 character should be filled with space so that the next value starting from 36 is not shifted to left column.

Code:
 
find from 25 to 35  -- replace with
2FMDK38C39B--AAAAAAAAAAA
1FMEU64    --BBBB       
5LMFU275   --CCCCC      
1ZVHT82H28 --DD         
           --Nodata



Code:
----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
3FADP4CJ6BM103485FP8FC022FMDK38C39B2010-08-212010-10-20
4M2EU38807UJ02689VT0ZD0M1FMEU64    2008-02-292010-12-27
1FMEU64E39UA36544NS1CD0M5LMFU275   2009-07-042010-12-21
1FAHP2EW0AG131631OQ9AA1A1ZVHT82H28 2010-01-162010-12-21
1FMEU3BE6AUF00576ER9AA1A           2010-08-072010-12-23
1FMEU33E18UB03690FR9AA1A           2008-11-082010-12-23


Code:
 
----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
3FADP4CJ6BM103485FP8FC02AAAAAAAAAAA2010-08-212010-10-20
4M2EU38807UJ02689VT0ZD0MBBBB       2008-02-292010-12-27
1FMEU64E39UA36544NS1CD0MCCCCC      2009-07-042010-12-21
1FAHP2EW0AG131631OQ9AA1ADD         2010-01-162010-12-21
1FMEU3BE6AUF00576ER9AA1ANodata     2010-08-072010-12-23
1FMEU33E18UB03690FR9AA1ANodata     2008-11-082010-12-23

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Perl: Search for string on line then search and replace text

Hi All, I have a file that I need to be able to find a pattern match on a line, search that line for a text pattern, and replace that text. An example of 4 lines in my file is: 1. MatchText_randomNumberOfText moreData ReplaceMe moreData 2. MatchText_randomNumberOfText moreData moreData... (4 Replies)
Discussion started by: Crypto
4 Replies

2. UNIX for Dummies Questions & Answers

Search for a string and replace the searched string in the same position in samefile

Hi All, My requisite is to search for the string "0108"(which is the year and has come in the wrong year format) in a particular column say 4th column in a tab delimited file and then replace it with 2008(the correct year format) in the same position where 0108 was found in the same file..The... (27 Replies)
Discussion started by: ganesh_248
27 Replies

3. Shell Programming and Scripting

Search, replace string in file1 with string from (lookup table) file2?

Hello: I have another question. Please consider the following two sample, tab-delimited files: File_1: Abf1 YKL112w Abf1 YAL054c Abf1 YGL234w Ace2 YKL150w Ace2 YNL328c Cup9 YDR441c Cup9 YDR442w Cup9 YEL040w ... File 2: ... ABF1 YKL112W ACE2 YLR131C (9 Replies)
Discussion started by: gstuart
9 Replies

4. Shell Programming and Scripting

awk - replace number of string length from search and replace for a serialized array

Hello, I really would appreciate some help with a bash script for some string manipulation on an SQL dump: I'd like to be able to rename "sites/WHATEVER/files" to "sites/SOMETHINGELSE/files" within the sql dump. This is quite easy with sed: sed -e... (1 Reply)
Discussion started by: otrotipo
1 Replies

5. Shell Programming and Scripting

String search and replace in multiple files.

Hello. I have five config files in /etc that I want to edit in one click for testing. I would like to make a script like this : #!/bin/bash # a_file="/etc/file_1" src_str="src_string_1" rpl_str="rpl_string_1" calling_sed_or_awk_or_whatelse $a_file search_for_all $src_str replace_with... (4 Replies)
Discussion started by: jcdole
4 Replies

6. Shell Programming and Scripting

awk + gsub to search multiple input values & replace with located string + extra text

Hi all. I have the following command that is successfully searching for any one of the strings on all lines of a file and replacing it with the instructed value. cat inputFile | awk '{gsub(/aaa|bbb|ccc|ddd/,"1234")}1' > outputFile This does in fact replace any occurrence of aaa, bbb,... (2 Replies)
Discussion started by: dazhoop
2 Replies

7. Shell Programming and Scripting

Search & Replace: Multiple Strings / Multiple Files

I have a list of files all over a file system e.g. /home/1/foo/bar.x /www/sites/moose/foo.txtI'm looking for strings in these files and want to replace each occurrence with a replacement string, e.g. if I find: '#@!^\&@ in any of the files I want to replace it with: 655#@11, etc. There... (2 Replies)
Discussion started by: spacegoose
2 Replies

8. UNIX for Dummies Questions & Answers

Search for a string,delete the line and replace with new string in a file

Hi Everyone, I have a requirement in ksh where i have a set of files in a directory. I need to search each and every file if a particular string is present in the file, delete that line and replace that line with another string expression in the same file. I am very new to unix. Kindly help... (10 Replies)
Discussion started by: Pradhikshan
10 Replies

9. UNIX for Beginners Questions & Answers

How to use a grep search to search for a specific string within multiple directories?

Lets say I have a massive directory which is filled with other directories all filled with different c++ scripts and I want a listing of all the scripts that contain the string: "this string". Is there a way to use a grep search for that? I tried: grep -lr "this string" * but I do not... (3 Replies)
Discussion started by: Circuits
3 Replies

10. UNIX for Beginners Questions & Answers

Search partial string in a file and replace the string - UNIX

I have the below string which i need to compare with a file and replace this string in the file which matches closely. Can anyone help me on this. string(Scenario 1)- user::r--,user::ourfrd:r-- String(Scenario 2)- user::r-- File **** # file: /local/Desktop/myfile # owner: me # group:... (6 Replies)
Discussion started by: sarathy_a35
6 Replies
PERROR(1)						       MySQL Database System							 PERROR(1)

NAME
perror - explain error codes SYNOPSIS
perror [options] errorcode ... DESCRIPTION
For most system errors, MySQL displays, in addition to an internal text message, the system error code in one of the following styles: message ... (errno: #) message ... (Errcode: #) You can find out what the error code means by examining the documentation for your system or by using the perror utility. perror prints a description for a system error code or for a storage engine (table handler) error code. Invoke perror like this: shell> perror [options] errorcode ... Example: shell> perror 13 64 OS error code 13: Permission denied OS error code 64: Machine is not on the network To obtain the error message for a MySQL Cluster error code, invoke perror with the --ndb option: shell> perror --ndb errorcode Note that the meaning of system error messages may be dependent on your operating system. A given error code may mean different things on different operating systems. perror supports the following options. o --help, --info, -I, -? Display a help message and exit. o --ndb Print the error message for a MySQL Cluster error code. o --silent, -s Silent mode. Print only the error message. o --verbose, -v Verbose mode. Print error code and message. This is the default behavior. o --version, -V Display version information and exit. COPYRIGHT
Copyright 2007-2008 MySQL AB, 2008-2010 Sun Microsystems, Inc. This documentation is free software; you can redistribute it and/or modify it only under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. This documentation is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with the program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or see http://www.gnu.org/licenses/. SEE ALSO
For more information, please refer to the MySQL Reference Manual, which may already be installed locally and which is also available online at http://dev.mysql.com/doc/. AUTHOR
Sun Microsystems, Inc. (http://www.mysql.com/). MySQL 5.1 04/06/2010 PERROR(1)
All times are GMT -4. The time now is 07:33 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy