Sponsored Content
Top Forums Shell Programming and Scripting Bash script reg-exp , replace , open and write Post 302659171 by molwiko on Wednesday 20th of June 2012 12:16:48 PM
Old 06-20-2012
hi actually I have files *.m that contain objective c code like this :
Code:
 tableviewlogin.backgroundView = nil;
    [welcometitle setFont:[UIFont fontWithName:FONTB size:FONTSIZETITLE]];
    [welcometitle setText:[MSharedFunctions UF8ErrorMessageForCode:@"LBL_10000"]];
    [welcometitle setTextAlignment:UITextAlignmentCenter];
    NSString *buttontitle = [MSharedFunctions UF8ErrorMessageForCode:@"LBL_10012"];
    [forgotpassword setTitle:buttontitle forState:UIControlStateNormal];
    [forgotpassword setTitle:buttontitle forState:UIControlStateHighlighted];
    [self.navigationItem setTitle:[MSharedFunctions UF8ErrorMessageForCode:@"LBL_10011"]];
    [[self tabBarItem] setTitle:[MSharedFunctions UF8ErrorMessageForCode:@"LBL_10804"]];

I want to generate a file that constant or whatever name which contain
Code:
 NSString *const C_LBL_10000 = @"LBL_10000";
 NSString *const C_LBL_10012 = @"LBL_10012";
 NSString *const C_LBL_10011 = @"LBL_10011";
 NSString *const C_LBL_10804 = @"LBL_10804";

//No duplication B/C it's variables
and replace this const variables into whatever file contain the match *.m
for example


Code:
 tableviewlogin.backgroundView = nil;
    [welcometitle setFont:[UIFont fontWithName:FONTB size:FONTSIZETITLE]];
    [welcometitle setText:[MSharedFunctions UF8ErrorMessageForCode:C_LBL_10000]];
    [welcometitle setTextAlignment:UITextAlignmentCenter];
    NSString *buttontitle = [MSharedFunctions UF8ErrorMessageForCode:C_LBL_10012];
    [forgotpassword setTitle:buttontitle forState:UIControlStateNormal];
    [forgotpassword setTitle:buttontitle forState:UIControlStateHighlighted];
    [self.navigationItem setTitle:[MSharedFunctions UF8ErrorMessageForCode:C_LBL_10011]];
    [[self tabBarItem] setTitle:[MSharedFunctions UF8ErrorMessageForCode:C_LBL_10804]];

My problem I have a lot of classes and I should do this work and rather than do it manually it we be coud to create script to do this work
I hope it's clear now

Thanks
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Using reg. exp. variable in AWK??

Any idea please: How to pass a reg. exp. variable to awk call in a shell??? Thank u #!/bin/sh reg_exp=name awk '/reg_exp/{ print; }' $1 (5 Replies)
Discussion started by: andy2000
5 Replies

2. Shell Programming and Scripting

usage...sed/awk/reg-exp ..in shell scripting

in shell scripting there is extensive usage of i> regular expression ii>sed iii>awk can anyone tell me the suitable contexts ...i mean which one is suitable for what kind of operation. like the reg-exp and sed seems to be doing the same job..i.e pattern matching (1 Reply)
Discussion started by: mobydick
1 Replies

3. Shell Programming and Scripting

reg exp question

Hi, Should be a difference between ']]*' and ']+' ? I use them in bash with sed and grep. Thanks (1 Reply)
Discussion started by: ynir
1 Replies

4. Shell Programming and Scripting

reg exp for sed

$ cat file.txt asd <AA>dev <LL>def <RR>sha This works for me: $ sed -r 's/^ .*<LL>def/\t<LL>my/' file.txt asd <AA>dev <LL>my <RR>sha But, this does not work for me: $ sed -r 's/^\s+<LL>def/\t<LL>my/' file.txt asd ... (1 Reply)
Discussion started by: demoprog
1 Replies

5. UNIX for Dummies Questions & Answers

extract a part of a path like (input: /etc/exp/home/bin ====> output: exp)

Hi, I need to make some extraction . with the following input to get the right output. input: /etc/exp/home/bin ====> output: exp and input: aex1234 ===> output: ex Thanks for your help, (4 Replies)
Discussion started by: yeclota
4 Replies

6. Shell Programming and Scripting

Perl reg exp

Hi, I am using the following piece of code for extracting some data from in between some tags ... $text =~ /<TAG1>(.*)<\/TAG1>.*<TAG2>(.*)<\/TAG2>.*<TAG3>(.*)<\/TAG4>.*<TAG5>(.*)<\/TAG5>/; $tag1=$1; print "\n$tag1"; But I am getting an error like Use of uninitialized value in... (1 Reply)
Discussion started by: King Nothing
1 Replies

7. Shell Programming and Scripting

perl reg-exp

$var1="LEN"; $VAR2="CODLENTT"; now, var2 contains var1(LEN).How do i check this in perl.... whether one string is a part of another..? if (<logic>) { my operation; } what'd be the logic.. (4 Replies)
Discussion started by: vijay_0209
4 Replies

8. Emergency UNIX and Linux Support

Need Help On REG EXP in unix

Respected All, I have a very big xml in that i want to search only below 3 lines. <target name ="UpgradePrimaryBox" depends ="configureBox1"> <echo> Finished Upgrading Primary Box </echo> </target> grep -i "<target.*UpgradePrimaryBox" this gives me the first line. then i need to match... (7 Replies)
Discussion started by: ameyrk
7 Replies

9. Shell Programming and Scripting

Bash script - coloring reg. expressions in text

Hi all, is there anyone good at bash who will help me? I need to use syntax ${string/pattern/replacement} The problematic part where I am stuck is: #!bin/bash text="A cat is on a mat." exp="cat" newexp="SOMECODEcatSOMECODE" newtext=${${text}/${exp}/${newexp}} == > ERROR "wrong... (4 Replies)
Discussion started by: JohnnyM77
4 Replies

10. Shell Programming and Scripting

How to use regular exp to replace the character in the file?

Hi Unix Gurus, yesterday I asked a question and got answer, it works fine. I have one more thing need to help in the code awk '{print substr($0,1,3)"xxx"substr($0,7)}' file If I have 50 charactor's need to be replaced, is there any easy way to use reg exp or I have to input 50 XXXXx......... (12 Replies)
Discussion started by: ken6503
12 Replies
RBASH(1)						      General Commands Manual							  RBASH(1)

NAME
rbash - restricted bash, see bash(1) RESTRICTED SHELL
If bash is started with the name rbash, or the -r option is supplied at invocation, the shell becomes restricted. A restricted shell is used to set up an environment more controlled than the standard shell. It behaves identically to bash with the exception that the follow- ing are disallowed or not performed: o changing directories with cd o setting or unsetting the values of SHELL, PATH, ENV, or BASH_ENV o specifying command names containing / o specifying a file name containing a / as an argument to the . builtin command o specifying a filename containing a slash as an argument to the -p option to the hash builtin command o importing function definitions from the shell environment at startup o parsing the value of SHELLOPTS from the shell environment at startup o redirecting output using the >, >|, <>, >&, &>, and >> redirection operators o using the exec builtin command to replace the shell with another command o adding or deleting builtin commands with the -f and -d options to the enable builtin command o using the enable builtin command to enable disabled shell builtins o specifying the -p option to the command builtin command o turning off restricted mode with set +r or set +o restricted. These restrictions are enforced after any startup files are read. When a command that is found to be a shell script is executed, rbash turns off any restrictions in the shell spawned to execute the script. SEE ALSO
bash(1) GNU Bash-4.0 2004 Apr 20 RBASH(1)
All times are GMT -4. The time now is 08:10 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy