Sponsored Content
Full Discussion: sed or awk editing help
Top Forums Shell Programming and Scripting sed or awk editing help Post 302467503 by mychmose on Friday 29th of October 2010 03:12:29 PM
Old 10-29-2010
Question sed or awk editing help

Hi all

I use aix (sadly).

I've got a file consisting of fields separated by commas, I need a sed or awk command that will delete all spaces between two commas as long as there are only spaces between the commas.

eg
Code:
,abc,    ,sd , ,dr at

would become
Code:
,abc,,sd ,,dr at

I have tried sed -e 's/, .*,/,,/g' but it does not work.

any ideas?

thanks in anticipation Smilie

Last edited by Scott; 11-01-2010 at 04:32 PM.. Reason: Code tags
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Editing File using awk/sed

Hello Awk Gurus, Can anyone of you help me with the below problem. I have got a file having data in below format pmFaultyTransportBlocks ----------------------- 9842993 pmFrmNoOfDiscRachFrames ----------------------- NULL pmNoRecRandomAccSuccess -----------------------... (4 Replies)
Discussion started by: Mohammed
4 Replies

2. Shell Programming and Scripting

Editing Commas in a textfile using sed

Hi guys task removing the last commas of 5th and 6th columns. The bug in the script is causing effect because of whitespaces around commas. I tried to delete white spaces first and running the above script. but still some where getting the results wrong. I already have a script to do this... (12 Replies)
Discussion started by: repinementer
12 Replies

3. Homework & Coursework Questions

String editing using sed? awk?

1. The problem statement, all variables and given/known data: Problem Statement for project: When an account is created on the CS Unix network, a public html directory is created in the account's home directory. A default web page is put into that directory. Some users replace or... (13 Replies)
Discussion started by: peage1475
13 Replies

4. Shell Programming and Scripting

problem in using sed command in editing a file

Hi all, I have a conf file, i want to update some entries in that conf file. Below is the code for that using a temporary file. sed '/workgroup=/ c\workgroup=Workgroup' /usr/local/netx.conf > /usr/local/netx.conf.tmp mv -f /usr/local/netx.conf.tmp /usr/local/netx.conf Sample contents of... (9 Replies)
Discussion started by: ranj14r
9 Replies

5. Shell Programming and Scripting

Comparison and editing of files using awk.(And also a possible bug in awk for loop?)

I have two files which I would like to compare and then manipulate in a way. File1: pictures.txt 1.1 1.3 dance.txt 1.2 1.4 treehouse.txt 1.3 1.5 File2: pictures.txt 1.5 ref2313 1.4 ref2345 1.3 ref5432 1.2 ref4244 dance.txt 1.6 ref2342 1.5 ref2352 1.4 ref0695 1.3 ref5738 1.2... (1 Reply)
Discussion started by: linuxkid
1 Replies

6. Shell Programming and Scripting

Line/Variable Editing for Awk sed Cut

Hello, i have a file, i open the file and read the line, i want to get the first item in the csv file and also teh third+6 item and wirte it to a new csv file. only problem is that using echo it takes TOO LONG: please help a newbie. below is my code: WorkingDir=$1 FileName=`cut -d ',' -f... (2 Replies)
Discussion started by: limamichelle
2 Replies

7. UNIX for Dummies Questions & Answers

sed editing help....

Hello all, I need some help with sed. seems like i cant get through it. So here is what i am trying. when i do ps -ef|grep bla blah ...like below...i get /u01/app/oracle/11g/bin/tnslsnr .... but i want to replace that string with something using sed. So basically i want to get rid of... (3 Replies)
Discussion started by: abdul.irfan2
3 Replies

8. UNIX for Dummies Questions & Answers

sed help finding and editing

With sed 1. I need to find a line that contains "DVM" and "73069". 2. I need to insert a double quote at the beginning of the first line of the file. These two have been driving me crazy for the last 45 minutes. Any help would be greatly appreciated. Thanks (3 Replies)
Discussion started by: nlassiter
3 Replies

9. Shell Programming and Scripting

editing file with awk cut and sed

HI All, I am new to unix. I have a file would like to do some editing by using awk, cut and sed. Could anyone help? This file contain 100 lines. There are one line for example: 2,"102343454",5060,"579668","579668","579668","SIP",,,"825922","035885221283026",1,268,"00:59:00.782 APR 17... (2 Replies)
Discussion started by: mimilaw
2 Replies

10. Shell Programming and Scripting

Editing files with sed or something similar

{ "AFafa": "FAFA","AFafa": "FAFA" "baseball":"soccer","wrestling":"dancing" "rhinos":"crocodiles","roles":"foodchain" } I need to insert a new line before the closing brackets "}" so that the final output looks like this: { "AFafa": "FAFA","AFafa": "FAFA"... (6 Replies)
Discussion started by: SkySmart
6 Replies
RDF::NS(3pm)						User Contributed Perl Documentation					      RDF::NS(3pm)

NAME
RDF::NS - Just use popular RDF namespace prefixes from prefix.cc VERSION
version 20120521 SYNOPSIS
use RDF::NS '20120521'; # check at compile time my $ns = RDF::NS->new('20120521'); # check at runtime $ns->foaf; # http://xmlns.com/foaf/0.1/ $ns->foaf_Person; # http://xmlns.com/foaf/0.1/Person $ns->foaf('Person'); # http://xmlns.com/foaf/0.1/Person $ns->URI('foaf:Person'); # http://xmlns.com/foaf/0.1/Person use RDF::NS; # get rid if typing '$' by defining a constant use constant NS => RDF::NS->new('20111208'); NS->foaf_Person; # http://xmlns.com/foaf/0.1/Person $ns->SPAQRL('foaf'); # PREFIX foaf: <http://xmlns.com/foaf/0.1/> $ns->TTL('foaf'); # @prefix foaf: <http://xmlns.com/foaf/0.1/> . $ns->XMLNS('foaf'); # xmlns:foaf="http://xmlns.com/foaf/0.1/" # get RDF::Trine::Node::Resource instead of strings use RDF::NS::Trine; # requires RDF::Trine $ns = RDF::NS::Trine->new('20120521'); $ns->foaf_Person; # iri('http://xmlns.com/foaf/0.1/Person') # load your own mapping $ns = RDF::NS::LOAD("mapping.txt"); # select particular mappings %map = $ns->SELECT('rdf,dc,foaf'); $uri = $ns->SELECT('foo|bar|doz'); # returns first existing namespace # instances of RDF::NS are just blessed hash references $ns->{'foaf'}; # http://xmlns.com/foaf/0.1/ bless { foaf => 'http://xmlns.com/foaf/0.1/' }, 'RDF::NS'; print (scalar %$ns) . "prefixes "; DESCRIPTION
Hardcoding URI namespaces and prefixes for RDF applications is neither fun nor maintainable. In the end we all use more or less the same prefix definitions, as collected at <http://prefix.cc>. This module includes all these prefixes as defined at specific snapshots in time. These snapshots correspond to version numbers of this module. By selecting particular versions, you make sure that changes at prefix.cc won't affect your scripts. The command line client rdfns is installed automatically with this module: $ rdfns -ttl rdf,foaf @prefix foaf: <http://xmlns.com/foaf/0.1/> . @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . This module does not require RDF::Trine, which is recommended nevertheless. You should install at least RDF::NS 0.140. If you prefer RDF::NS to return instances of RDF::Trine::Node::Resource instead of plain strings, use RDF::NS::Trine. The code repository of this module also contains an update script <https://github.com/nichtich/RDF-NS/blob/master/update.pl> to download the current prefix-namespace mappings from <http://prefix.cc>. METHODS
new ( $version [, %options ] ) Create a new namespace mapping with a selected version (mandatory). The special version string "any" can be used to get the newest mapping - actually this is $RDF::NS::VERSION, but you should better select a specific version, as mappings can change, violating backwards compatibility. Supported options include "warn" to enable warnings. LOAD ( $file [, %options ] ) Load namespace mappings from a particular tab-separated file. See NEW for supported options. URI ( $short | "<$URI>" ) Expand a prefixed URI, such as "foaf:Person" or "foaf_Person". Alternatively you can expand prefixed URIs with method calls, such as "$ns->foaf_Person". If you pass an URI wrapped in "<" and ">", it will not be expanded but returned as given. TTL ( prefix[es] ) Returns a Turtle/Notation3 @prefix definition or a list of such definitions in list context. Prefixes can be passed as single arguments or separated by commas, vertical bars, and spaces. SPARQL ( prefix[es] ) Returns a SPARQL PREFIX definition or a list of such definitions in list context. Prefixes can be passed as single arguments or separated by commas, vertical bars, and spaces. XMLNS ( prefix[es] ) Returns an XML namespace declaration or a list of such declarations in list context. Prefixes can be passed as single arguments or separated by commas, vertical bars, and spaces. TXT ( prefix[es] ) Returns a list of tabular-separated prefix-namespace-mappings. BEACON ( prefix[es] ) Returns a list of BEACON format prefix definitions (not including prefixes). SELECT ( prefix[es] ) In list context, returns a sorted list of prefix-namespace pairs, which can be used to assign to a hash. In scalar context, returns the namespace of the first prefix that was found. Prefixes can be passed as single arguments or separated by commas, vertical bars, and spaces. MAP ( $code [, prefix[es] ] ) Internally used to map particular or all prefixes. Prefixes can be selected as single arguments or separated by commas, vertical bars, and spaces. In scalar context, $_ is set to the first existing prefix (if found) and $code is called. In list context, found prefixes are sorted at mapped with $code. GET ( $uri ) This method is used internally to create URIs as return value of the URI method and all lowercase shortcut methods, such as "foaf_Person". By default it just returns $uri unmodified. SEE ALSO
There are several other CPAN modules to deal with IRI namespaces, for instance RDF::Trine::Namespace, RDF::Trine::NamespaceMap, RDF::Prefixes, RDF::Simple::NS, RDF::RDFa::Parser::Profile::PrefixCC, Class::RDF::NS, XML::Namespace, XML::CommonNS etc. AUTHOR
Jakob Voss COPYRIGHT AND LICENSE
This software is copyright (c) 2012 by Jakob Voss. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. perl v5.14.2 2012-05-21 RDF::NS(3pm)
All times are GMT -4. The time now is 02:25 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy