incorporating a regular expression statement in a shell script (.sh)


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting incorporating a regular expression statement in a shell script (.sh)
# 1  
Old 08-31-2012
incorporating a regular expression statement in a shell script (.sh)

I do have a shell file where I call many unix commands . I would like to add a regular expression step in that shell file, where a text file, say Test.txt has to be openned and all the :'s should be replaced.
Basically apply the follwoing regular expression:
Code:
:%s/://g

to that particular text file, which is generated from a previous command in that shell script.
Please let me know
# 2  
Old 08-31-2012
No need for a regular expression. Use tr to delete the colons.
# 3  
Old 08-31-2012
For a more general case you could use sed.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

SHELL: UNIX : Ls regular expression not working when used with variables

If i do below command in unix prompt which static values (ie 27..97), it is working fine and gives desired output >ls -d $WORKDIR/batch/somefilename_{27..97}.* 2>/dev/null somefilename_27.sometxt somefilename_28.sometxt somefilename_29.sometxt .. somefilename_97.sometxt But if i want... (2 Replies)
Discussion started by: haiderali
2 Replies

2. Shell Programming and Scripting

Help with Regular expression in ping script

Hi everyone, ping www.google.com | awk 'BEGIN{FS="+";}{if ($10 ~ (/^$/) || (/^\.?/)) print "SLOW"; else print $0} output awk: warning: escape sequence `\=' treated as plain `=' PING www.google.com (xxx.xxx.xxx.xxx) 56(84) bytes of data. 64 bytes from xxx.xxx.xxx.xxx icmp_req=2 ttl=128... (3 Replies)
Discussion started by: Apollo
3 Replies

3. Shell Programming and Scripting

regular expression with shell script to extract data out of a text file

hi i am trying to extract some specific data out of a text file using regular expressions with shell script that is using a multiline grep .. and the tool i am using is pcregrep so that i can get compatibility with perl's regular expressions for a sample data like this, i am trying to grab... (6 Replies)
Discussion started by: vemkiran
6 Replies

4. Programming

Perl: How to read from a file, do regular expression and then replace the found regular expression

Hi all, How am I read a file, find the match regular expression and overwrite to the same files. open DESTINATION_FILE, "<tmptravl.dat" or die "tmptravl.dat"; open NEW_DESTINATION_FILE, ">new_tmptravl.dat" or die "new_tmptravl.dat"; while (<DESTINATION_FILE>) { # print... (1 Reply)
Discussion started by: jessy83
1 Replies

5. Shell Programming and Scripting

Regular expression inside case statement notworking

I have the following script: For catching errors like: But the regular expression ERROR*memory inside case doesn't seem to be working. The output of bash -x scriptname is: Please help (5 Replies)
Discussion started by: proactiveaditya
5 Replies

6. Shell Programming and Scripting

TCL Script Regular expression

Hi , I'm working on tcl script to extract specific data . I tried to use regular expression (new to regular expression) but I couldn't get it. here is a smaple of what I'm trying to extract from: + 20.167 0 1 cbr 500 ------- 2 5.0 1.3 3091 57612 d 20.167 0 1 cbr 500 ------- 2 5.0 1.3 3091... (1 Reply)
Discussion started by: ENG_MOHD
1 Replies

7. Shell Programming and Scripting

Need help in Regular expression in bash shell

hi, I have written a script to search MAC address in a given directory. MAC address would be in format XX.XX.XX.XX. The digits contain hexadecimal numbers. For this i have used grep as follows. grep -rn '^\{1,2\}\.\{1,2\}\.\{1,2\}\.\{1,2\}\$' * This is not working as required.... (17 Replies)
Discussion started by: flamingo_l
17 Replies

8. Shell Programming and Scripting

problem with Regular expression as input in shell script

Hi, I have script which will take a string as input and search in a file. But when I want to search a pattern which has special characters script is ignoring it. For example: I want to search a pattern "\.tumblr\.com". shell script is removing \ (backslah) and trying to search... (7 Replies)
Discussion started by: Anjan1
7 Replies

9. Shell Programming and Scripting

how to use regular expression in Bash Shell Scripting

Hi, Actually i have written one test.sh (shell program) in bash. Here i have a variables $a which stored the value package1. Now I want to write a regular expression inside the if command that "if $a variable contains letter p in the begining of the value package1 then it is coming true.... (5 Replies)
Discussion started by: sunitachoudhury
5 Replies

10. Shell Programming and Scripting

using regular expression an shell script!!

I want to check if the first argument of my shell script starts with a specifiec string? Any Idea?? Thank u (3 Replies)
Discussion started by: andy2000
3 Replies
Login or Register to Ask a Question