nixCraft Linux Forum

nixCraft

Linux Tech Support Forum

Replaceing [] and white space with sed

This is a discussion on Replaceing [] and white space with sed within the Shell scripting forums, part of the Development/Scripting category; how do I replace [] with sed example: pic001.tif [12] 853x480 to: pic001.tif : 853x480 I need to remove [] ...


Go Back   nixCraft Linux Forum > Development/Scripting > Shell scripting

Register FAQ Members List Calendar Forgotten your password? Mark Forums Read
  #1 (permalink)  
Old 02-12-2007, 11:05 AM
Junior Member
User
 
Join Date: Feb 2007
Posts: 6
Rep Power: 0
TiredOrangeCat
Default Replaceing [] and white space with sed

how do I replace [] with sed

example:
pic001.tif[12] 853x480
to:
pic001.tif:853x480

I need to remove [] and its contents and replace it with : , but I cannot get the sed command to recognize [] as a removable object or to print :
I have tried disabling it but alas I am running in circles.
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 02-12-2007, 11:22 PM
nixcraft's Avatar
Never say die
User
 
Join Date: Jan 2005
Location: BIOS
My distro: Ubuntu
Posts: 1,036
Rep Power: 10
nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute
Default

you can try something as follows:
Code:
echo 'pic001.tif[12] 853x480' |  sed 's/\[[[:digit:]]*]/:/' | sed 's/\s//g'
Output:
pic001.tif:853x480
__________________
Vivek | My personal blog
Linux Evangelist
Play hard stay cool
Reply With Quote
  #3 (permalink)  
Old 02-12-2007, 11:58 PM
Junior Member
User
 
Join Date: Feb 2007
Posts: 6
Rep Power: 0
TiredOrangeCat
Default

awesome thanks, I was missing a set of brackets
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads

Thread Thread Starter Forum Replies Last Post
Enabling Swap Space - Redhat aaru Linux software 8 03-24-2008 07:18 PM
ping: sendmsg: No buffer space available linuxnightowl84 Networking, Firewalls and Security 3 04-28-2007 04:14 AM
mod_rewrite with convertion of space and / to _ kasimani Networking, Firewalls and Security 0 03-13-2007 12:52 PM
mod_rewrite with convertion of space and / to _ kasimani Web servers 0 03-13-2007 12:51 PM
script for free space of hard drive zafar466 Shell scripting 1 01-16-2007 09:33 PM


All times are GMT +5.5. The time now is 09:03 PM.


Powered by vBulletin® Version 3.7.4 - Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36