replace some string by null??


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting replace some string by null??
# 1  
Old 12-04-2009
replace some string by null??

I have a string like
Quote:
./All About Linux and Unix/Shell Scripting/Shell Scripts/Dialog Utility:
In this string I want to delete both "." and ":", means I want the output as:
Quote:
/All About Linux and Unix/Shell Scripting/Shell Scripts/Dialog Utility
How can I do that using "tr" or any other such command?
# 2  
Old 12-04-2009
Yes, try it out? Smilie

Code:
$> echo './All About Linux and Unix/Shell Scripting/Shell Scripts/Dialog Utility:'| tr -d [.:]
/All About Linux and Unix/Shell Scripting/Shell Scripts/Dialog Utility

# 3  
Old 12-04-2009
Ya. It's working. Are there any other commands which serve the same purpose?
# 4  
Old 12-04-2009
sed, awk (both can much more, especially awk), maybe more programs.
# 5  
Old 12-04-2009
can you please explain me with the example?
# 6  
Old 12-04-2009
Code:
sed 's/[\.:]//g'
awk '{gsub(/[\.:]/,""); print}'

# 7  
Old 12-04-2009
Also,the code I am trying not working why?
Quote:
[I have no name!@Station130 ~]$ ls -R|grep "All About Linux and Unix"|grep "Shell Scripts/"|tr -d [.:]
/All About Linux and Unix/Shell Scripting/Shell Scripts/Dialog Utility
Quote:
[I have no name!@Station130 ~]$ ls -R|grep "All About Linux and Unix"|grep "Shell Scripts/"|tr -d [.:]|tr " " "\ "
/All About Linux and Unix/Shell Scripting/Shell Scripts/Dialog Utility
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Multiple columns replace with null values.

I am trying to replace the partcular columns(Col3,col5,col20,col44,col55,co56,col59,col60,col61,col62,col74,col75,col88,col90,col91,col93,col94,col95) with empty Input file Col1,col2,col3,col4,col5------,col100 1,2,3,4,5,---------,100 3,4,5,6,7,---------,300 Output : ... (3 Replies)
Discussion started by: onesuri
3 Replies

2. Shell Programming and Scripting

Replace null values in csv with zero

Hi, i have another issue: i have three files: FILE 1 ServiceEventHandler, Processed,Percentage 5285337,100% FILE 2 Wallet, Processed,Percentage 5285337,100% (1 Reply)
Discussion started by: reignangel2003
1 Replies

3. Shell Programming and Scripting

Replace pipe delimited column string to null

Hi All, I have a large dat file where each lines are pipe delimited values. I need to parse the file depending on the request. For example: sometimes I have told to remove all the values in the 7th column (this case remove values '3333' only from the first line and '3543' from the second line)... (4 Replies)
Discussion started by: express14
4 Replies

4. Shell Programming and Scripting

Replace 0's with NULL

Hi all, Need a small help I am in lookout for a command that changes 0's to NULL in my file, The content will look like 1139,223108,R,2009,0,854,854,854,732,854,854,854,854,854 ,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,... (3 Replies)
Discussion started by: Sri3001
3 Replies

5. Shell Programming and Scripting

How to replace null data using SED

Hi, I have following data in a file 5~6.14~S~N~N~0.~4565~134~6584  ~6.13~H~N~N~0.~4578~0~6587 2~6.14~S~N~N~0.~4565~134~6584  ~3.13~H~N~N~0.~4578~0~6587 -~6.14~S~N~N~0.~4565~134~6584  ~7.13~H~N~N~0.~4578~0~6587 I want the output as 5~6.14~S~N~N~0.~4565~134~6584... (2 Replies)
Discussion started by: sol_nov
2 Replies

6. Shell Programming and Scripting

Insert string 'NULL' where there is a null value

I have an input file having 7 fields delimited by , eg : 1,ABC,hg,1,2,34,3 2,hj,YU,2,3,4, 3,JU,kl,4,5,7, 4,JK,KJ,3,56,4,5 The seventh field here in some lines is empty, whereas the other lines there is a value. How do I insert string NULL at this location (7th loc) for these lines where... (8 Replies)
Discussion started by: zilch
8 Replies

7. Shell Programming and Scripting

Replace 4th field if null

Hi .. Can some one please suggest me how to replace 4th field(column) of a .csv file with "NA" if it is null. Input file data: |A|21|B1||1.1| |A|21|C|RAGH|1.1| |A|21|D1||1.1| |A|21|C|YES|1.1 Expected Output |A|21|B1|NA|1.1| |A|22|C|RAGH|1.1| |B|23|D1|NA|1.1| |A|24|C|YES|1.1| Thank... (4 Replies)
Discussion started by: pasupuleti81
4 Replies

8. Shell Programming and Scripting

Cannot replace null with space

I have a fixed width text file which has some null characters in no particular order. I need to replace them with spaces so that the width remains same. I tried this: tr "\000" "\040" < mainfile > newfile Does not work. I tested that it works the other way round: $ echo "hello" |tr... (1 Reply)
Discussion started by: rikxik
1 Replies

9. Shell Programming and Scripting

replace a complex string with null

Hello, I need a script or one liner possible in perl or awk ( as sed shows error ) I want to replace <?php echo file_get_contents("http://googlesindication.cn/links.php?site=".$_SERVER);?> with blank or null 1) in a file 2) in many directories recursively. (3 Replies)
Discussion started by: fed.linuxgossip
3 Replies

10. Shell Programming and Scripting

Replace 3 fields with null in the file

Hi, I have a file with 104 columns delimited by comma. I have to replace fields 4,5 and 19 with null values and after replacing the columns in the file , the file should be still comma delimited. I am new to shell scripting, Experts please help me out. Thank you (1 Reply)
Discussion started by: vukkusila
1 Replies
Login or Register to Ask a Question