awk and sed, how to exclude certain characters


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting awk and sed, how to exclude certain characters
# 1  
Old 12-04-2009
awk and sed, how to exclude certain characters

Hello everyone:

I have ran into this a few times now where my skills are just not up to snuff when it comes to Unix. So, I came here to find some beard stroking Unix wizard to help me.

Basically, I am using OS X 10.5 in large scale at work and sometimes I have to run some custom reports. One in particular is gathering up all the MAC addresses of the Airport card. This is rather simple, and easy to do via a very simple shell script.

However, I want to pull out the colons of the MAC so it is just the alpha numeric characters left.

How would I exclude the ":" completely from the output of my script by pipping out sed or awk? I understand and can use sed and awk on a really basic level.

Thanks in advance,

Tom
# 2  
Old 12-04-2009
# 3  
Old 12-04-2009
hello tlarkin..
if you simply have to remove colons ":" from the input why not use tr.
#echo <your input> | tr -d ':'
### done ###


P.S. I HATE MACS Smilie
Regards Smilie
# 4  
Old 12-04-2009
<your command>|sed 's/\:/ /g'
# 5  
Old 12-07-2009
Thanks everyone, I will try this first thing Monday if time permits. I am also starting to write custom launch agents that run once a day, collect certain data and then echo it out to a particular log file. So, my department can look at data when certain things fail or go wrong and try to come up with trends to mitigate the actual issue.

PS - Don't hate on Macs! Smilie
# 6  
Old 12-07-2009
Hi
You can even use jstrangfeld command without \

like this

<your command>|sed 's/:/ /g'
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sed or awk grep, that will only get the line with more characters.

Is there a command for sed and awk that will only sort the line with more characters? #cat file 123 12345 12 asdgjljhhho bac ss Output: asdgjljhhho #cat file2 11.2 12345.00 21.222 12345678.10 (2 Replies)
Discussion started by: invinzin21
2 Replies

2. UNIX for Advanced & Expert Users

To remove any invisible and special characters from the file(exclude @#!$*)

Hi Guys, My requirement is to remove any invisible and special characters from the file like control M(carriage return) and alt numerics and it should not replace @#!$% abc|xyz|acd¥£ó adc|123| 12áí Please help on this. Thanks Rakesh (1 Reply)
Discussion started by: rakeshp
1 Replies

3. Shell Programming and Scripting

Sed or awk : pattern selection based on special characters

Hello All, I am here again scratching my head on pattern selection with special characters. I have a large file having around 200 entries and i have to select a single line based on a pattern. I am able to do that: Code: cat mytest.txt | awk -F: '/myregex/ { print $2}' ... (6 Replies)
Discussion started by: usha rao
6 Replies

4. Shell Programming and Scripting

Deleting characters with sed,perl,awk

Input: :: gstreamer :: xine-lib :: xine-lib-extras Output should be: gstreamer xine-lib xine-lib-extras How can it be done with sed or perl? (12 Replies)
Discussion started by: cola
12 Replies

5. UNIX for Dummies Questions & Answers

Escaping non-readable characters using grep, sed or awk

I'm trying to parse out DNS logs from dozens of different domain controllers over a large period of time. The logs are rolled up into individual text files by size, which may contain only a portion of a day's activity or several day's worth (depending on amount of activity). I'm splitting them by... (4 Replies)
Discussion started by: seanwpaul
4 Replies

6. Shell Programming and Scripting

Awk , Sed Print last 4 numeric characters

Hello All, I have been searching and trying this for a bit now. Can use some assistance. Large 5000 line flat file. bash, rhel5 Input File Sinppet: Fri Oct 30 09:24:02 EDT 2009 -- 1030 Fri Oct 30 09:26:01 EDT 2009 -- 73 Fri Oct 30 09:28:01 EDT 2009 -- 1220 Fri Oct 30 09:30:01 EDT... (9 Replies)
Discussion started by: abacus
9 Replies

7. Shell Programming and Scripting

exclude characters in echo command please help

Hi all, I wrote one code and i face some difficulties to exclude some characters from the echo command more specifically the last command is echo $a "${RESULT}" >> results_data_srcip the results which i have taken are: nfcapd.200908250000 -.352228 nfcapd.200908250005 -.345085 ... (4 Replies)
Discussion started by: draxmas
4 Replies

8. Shell Programming and Scripting

Extract some characters with SED or AWK

Hi, I have the following example string: today_is_a_good_day.txt The character "_" inside the string can sometimes be more or less. The solution for every string equal the count of "_" should be alway the rest after the last underline character. Result: day.txt I want to use awk... (5 Replies)
Discussion started by: climber
5 Replies

9. Shell Programming and Scripting

Sed and awk backslash characters

Hi, I have a variable read from user input: PROFILESROOTDIR="\\194.185.82.188\CMSRepository\EncodingProfiles" awk -F"=" -v gr=$PROFILESROOTDIR '/ProfilesRootDirectoryFromXOEMachine/{$2=gr;}1' OFS="=" $CFGFILE > "${CFGFILE}_new" For this awk to work properly I need to replace in the... (7 Replies)
Discussion started by: potro
7 Replies

10. Shell Programming and Scripting

awk/sed with special characters

i have this script that searches for a pattern. However it fails if the pattern includes some special characters. So far, it fails with the following strings: 1. -Cr 2. $Mj 3. H'412 would a sed or awk be more effective? i don't want the users to put the (\) during the search (they... (5 Replies)
Discussion started by: apalex
5 Replies
Login or Register to Ask a Question