Sponsored Content
Top Forums Shell Programming and Scripting Find & replace --> create a new file Post 302660101 by karthi_mrkg on Friday 22nd of June 2012 05:32:01 AM
Old 06-22-2012
Find & replace --> create a new file

Hi All,

I have a unix shell script file as below.
Quote:


. get_dates.sh
DD=$(printf $LASTREPDATE | cut -c1-2)
MM=$(printf $LASTREPDATE | cut -c3-4)
YY=$(printf $LASTREPDATE | cut -c7-8)
YYYY=$(printf $LASTREPDATE | cut -c5-8)
LASTREPDATE="$DD$MM$YYYY"
LASTREPDATE_I="$DD$MM$YYYY"

DD=$(printf $CURRREPDATE | cut -c1-2)
MM=$(printf $CURRREPDATE | cut -c3-4)
YY=$(printf $CURRREPDATE | cut -c7-8)
CURRREPDATE_I="$DD$MM$YYYY"

FILENAME248="BW3_*248S"


. $APPAREA/check_file.sh "$FILENAME248*_$CURRREPDATE_I" 1>>$JOBOUTFILE 2>>$JOBOUTFILE
RETCODE=$?
if [ $RETCODE -ne 0 ]
then
FILENAME="$FILENAME248*_$LASTREPDATE_I*.CSV*"
cp $BACKUPAREA/$FILENAME $INBOUNDAREA 1>>$JOBOUTFILE 2>>$JOBOUTFILE
if [ $? -ne 0 ]
then
FILENAME=$FILENAME248"_RD"$LASTREPDATE.TXT.gz
FILENAME1=$FILENAME248"_RD"$LASTREPDATE.TXT
cp $BACKUPAREA/$FILENAME $INBOUNDAREA/ 1>>$JOBOUTFILE 2>>$JOBOUTFILE
if [ $? -ne 0 ]
then
write_log.sh "BW3_248-RESTORE" "FAILED 1"
exit 0
fi
gunzip $INBOUNDAREA/$FILENAME 1>>$JOBOUTFILE 2>>$JOBOUTFILE
My task is

a)to replace 248 to 350 and need to create a new file as BW3_350.sh
b)to replace 248 to 380 and need to create a new file as BW3_380.sh
c)to replace 248 to 320 and need to create a new file as BW3_320.sh

there is no change in the file apart from the above mentioned one. I have to create around 250 files. So i need a to script to do this Smilie
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Find & Replace

I get a text file with 70+ columns (seperated by Tab) and about 10000 rows. The 58th Column is all numbers. But sometimes 58th columns has "/xxx=##" after the numeric data. I want to truncate this string using the script. Any Ideas...:confused: (3 Replies)
Discussion started by: gagansharma
3 Replies

2. UNIX for Dummies Questions & Answers

find, mv and create unknown parent & subfolders

I searched the forum rather thoroughly but still could not find the answer. Hopefully the solution is right under my nose. Here what I need to do, move older data to a Archive folder that is 18 months old and older. I would like to use the following command, find departmentx/* -mtime 530... (5 Replies)
Discussion started by: cheeba
5 Replies

3. Shell Programming and Scripting

find & incremental replace?

Looking for a way using sed/awk/perl to replace port numbers in a file with an incrementing number. The original file looks like... Host cmg-iqdrw3p4 LocalForward *:9043 localhost:9043 Host cmg-iqdro3p3a LocalForward *:10000 localhost:10000 Host cmg-iqdro3p3b LocalForward... (2 Replies)
Discussion started by: treadwm
2 Replies

4. Shell Programming and Scripting

find & replace with user input

Trying to create a script/executable to replace "abc" text string in "myfile.htm" with input from a pop-up field. For example, launch this thing and a prompt is popped up asking the user to input what "abc" should be replaced with, then it inserts what the user inputs in place of abc in the... (3 Replies)
Discussion started by: mike909
3 Replies

5. Shell Programming and Scripting

Find & Replace string in multiple files & folders using perl

find . -type f -name "*.sql" -print|xargs perl -i -pe 's/pattern/replaced/g' this is simple logic to find and replace in multiple files & folders Hope this helps. Thanks Zaheer (0 Replies)
Discussion started by: Zaheer.mic
0 Replies

6. Shell Programming and Scripting

find & replace comma in a .csv file.

HI, Please find the text below. I receive a .csv file on server. I need the comma(,) in the second column to be replaced by a semi-colon( ; ). How to do it. Please help. Sample text: "1","lastname1,firstname1","xxxxxx","19/10/2009","23/10/2009","0","N","Leave"... (2 Replies)
Discussion started by: libin4u2000
2 Replies

7. UNIX for Dummies Questions & Answers

How to compare 2 files & get specific value & replace it in other file.

Hiiii Friends I have 2 files with huge data. I want to compare this 2 files & if they hav same set of vales in specific rows & columns i need to get that value from one file & replace it in other. For example: I have few set data of both files here: a.dat: PDE-W 2009 12 16 5 29 11.11 ... (10 Replies)
Discussion started by: reva
10 Replies

8. Shell Programming and Scripting

replace & with & xml file

Hello All I have a xml file with many sets of records like this <mytag>mydata</mytag> <tag2>data&</tag2> also same file can be like this <mytag>mydata</mytag> <tag2>data&</tag2> <tag3>data2&amp;data3</tag3> Now i can grep & and replace with &amp; for whole file but it will replace all... (4 Replies)
Discussion started by: lokaish23
4 Replies

9. UNIX for Dummies Questions & Answers

Find & Replace command - Fasta file

Hi all ! I have a fasta file that looks like that: >Sequence1 RTYIPLCASQHKLCPITFLAVK (it's just an example, obviously in reality I have several pairs of lines like that) Using UNIX command(s), would it be possible to replace all the characters except the "C" of the second line only by... (7 Replies)
Discussion started by: Cevin21
7 Replies

10. UNIX for Dummies Questions & Answers

Find & Replace

Hi I am looking to rename the contents of this dir, each one with a new timestamp, interval of a second for each so it the existing format is on lhs and what I want is to rename each of these to what is on rhs..hopefully it nake sense CDR.20060505.150006.gb CDR.20121211.191500.gb... (3 Replies)
Discussion started by: rob171171
3 Replies
GIT-SH-I18N(1)							    Git Manual							    GIT-SH-I18N(1)

NAME
git-sh-i18n - Git's i18n setup code for shell scripts SYNOPSIS
. "$(git --exec-path)/git-sh-i18n" DESCRIPTION
This is not a command the end user would want to run. Ever. This documentation is meant for people who are studying the Porcelain-ish scripts and/or are writing new ones. The 'git sh-i18n scriptlet is designed to be sourced (using .) by Git's porcelain programs implemented in shell script. It provides wrappers for the GNU gettext and eval_gettext functions accessible through the gettext.sh script, and provides pass-through fallbacks on systems without GNU gettext. FUNCTIONS
gettext Currently a dummy fall-through function implemented as a wrapper around printf(1). Will be replaced by a real gettext implementation in a later version. eval_gettext Currently a dummy fall-through function implemented as a wrapper around printf(1) with variables expanded by the git-sh- i18n--envsubst(1) helper. Will be replaced by a real gettext implementation in a later version. GIT
Part of the git(1) suite Git 1.8.3.1 06/10/2014 GIT-SH-I18N(1)
All times are GMT -4. The time now is 11:03 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy