Sponsored Content
Full Discussion: Lines with comma
Top Forums Shell Programming and Scripting Lines with comma Post 303043558 by MadeInGermany on Friday 31st of January 2020 12:01:15 PM
Old 01-31-2020
Quote:
Originally Posted by zouhair
Code:
grep ^, a.txt

^ beginning of the line
, a comma
So it prints all lines that start with a , i.e. if the 1st field is empty.
Perhaps you want to only print if all fields are empty?
BTW it is better to put the RegularExpression string in quotes, in order to avoid unwanted substitiutions from the shell : '^,'
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Joining three lines with comma separation

I have a file that looks like this: G. KRESSLAR 9618 W. APPALOOSA DRIVE SUN CITY, AZ 85373 SHIRLEY ALLEN 7272 W. VIA MONTOYA DRIVE GLENDALE, AZ 85310 LOUIS VALDEZ 244441 N. 86TH AVENUE PEORIA, AZ 85383 DONNA NEWBON 3231 W. DENTON #D PHOENIX, AZ 85017 SARAH WILSON 6534 W. PALO... (3 Replies)
Discussion started by: BCarlson
3 Replies

2. Shell Programming and Scripting

Place a comma on lines

Is it possible to place a comma in the desired places, like 10spaces after or 15 spaces after, irrespective of the contents??? Ex:File: TEST TEST: vimalthomaswants to place a comma can he do it in the desired places? as per the above file, i need to place a comma after 10th space... (4 Replies)
Discussion started by: vj8436
4 Replies

3. Shell Programming and Scripting

Script to Check & Edit Content of a file (Addition of comma in each lines of code)

Hi all, I need to write an automated bash shell script which performs such operations: 1. Grep the header of everyline with the initial of "T" in "FILE_A" 2. Perform a for loop, Count the numbers of comma in the line of code, if (no. of comma < 17) ADD the comma until 17; ... (2 Replies)
Discussion started by: big_nutz
2 Replies

4. UNIX for Dummies Questions & Answers

sort comma separated lines by specific columns

Hello, I have a file which lines' words are comma separated: aa, bb, cc, uu b, ee, ff bb, cc, zz, ee, ss, kk oo, bb, hh, uu a, xx, ww tt, aa, dd, yy aa, gg I want to sort first by second column and in case of tie by fourth column with sort command. So the output would be: ... (4 Replies)
Discussion started by: asanchez
4 Replies

5. Shell Programming and Scripting

Make multiple lines into single quoted comma separated Linux

Hi, I want to change a file file1.txt: 1234 3456 2345 6789 3456 2333 4444 As, file2.txt in Linux: '1234','3456','2345','6789','3456','2333','4444' Could someone please help me. (Single liner sed, awk will be welcome!) (7 Replies)
Discussion started by: wiweq05
7 Replies

6. Shell Programming and Scripting

Combining multiple block of lines in one comma separated line

Hi Everyone, On my Linux box I have a text file having block of few lines and this block lines separated by one blank line. I would like to format and print these lines in such a way that this entire block of lines will come as single comma separated line & again next block of lines in next... (7 Replies)
Discussion started by: gr8_usk
7 Replies

7. UNIX for Dummies Questions & Answers

How to convert a comma delimited string to records or lines of text?

Hi, I am not sure if I've posted this question before. Anyway, I previously asked about converting lines of text into a comma delimited string. Now I am needing to do the other way around ... :( :o Can anyone advise how is this possible? Example as below: Converting records/lines to... (2 Replies)
Discussion started by: newbie_01
2 Replies

8. Shell Programming and Scripting

Comma separated values to individual lines

My OS : RHEL 6.7 I have a text file with comma separated values like below $ cat testString.txt 'JOHN' , 'KEITH' , 'NEWMAN' , 'URSULA' , 'ARIANNA' , 'CHENG', . . . . I want these values to appear like below 'JOHN' , 'KEITH' , 'NEWMAN' , 'URSULA' , 'ARIANNA' , 'CHENG', .... (4 Replies)
Discussion started by: kraljic
4 Replies

9. Shell Programming and Scripting

awk to parse comma separated field and removing comma in between number and double quotes

Hi Experts, Please support I have below data in file in comma seperated, but 4th column is containing comma in between numbers, bcz of which when i tried to parse the file the column 6th value(5049641141) is being removed from the file and value(222.82) in column 5 becoming value of column6. ... (3 Replies)
Discussion started by: as7951
3 Replies

10. UNIX for Beginners Questions & Answers

Need help on an old post - How to convert a comma delimited string to records or lines of text?

Hi, Apologies in advance to the moderator if I am posting this the wrong way. I've searched and found the solution to an old post but as it is a very old post, I don't see an option to update it with additional question. The question I have is in relation to the following post: How to... (6 Replies)
Discussion started by: newbie_01
6 Replies
Net::SIP::Packet(3pm)					User Contributed Perl Documentation				     Net::SIP::Packet(3pm)

NAME
Net::SIP::Packet - handling of SIP packets SYNOPSIS
use Net::SIP::Packet; my $pkt = eval { Net::SIP::Packet->new( $sip_string ) } or die "invalid SIP packet"; $pkt->get_header( 'call-id' ) || die "no call-id"; $pkt->set_header( via => @via ); print $pkt->as_string; DESCRIPTION
This module implements the parsing, manipulation and creation of SIP packets according to RFC3261. NET::SIP::Packet's objects can be created by parsing a string containing the SIP packet or by constructing it from parts, e.g. header keys and values, body, method+URI (requests) or code+text (responses). All parts can be manipulated and finally the string representation of the manipulated packet can be (re)created. For dealing with requests and responses directly usually the subclasses Net::SIP::Request or Net::SIP::Response will be used instead. EXAMPLES
# create packet from string my $invite = Net::SIP::Packet->new( <<'EOS' ); INVITE sip:you@example.com SIP/2.0 From: <sip:me@example.com> To: <sip:you@example.com> ... EOS # show and manipulate some header print "callid=".$invite->get_header( 'call-id' )." "; print "route=".join( ",", $invite->get_header( 'route' ))." "; $invite->set_header( 'via' => [ $via1,$via2,.. ] ); # get resulting string representation print $invite->as_string; # create packet from parts my $resp = Net::SIP::Packet->new( 200, 'Ok', { to => '<sip:you@example.com>', from => '<sip:me@example.com>',.. } Net::SIP::SDP->new(...) ); # and get the packet as string print $resp->as_string; CONSTRUCTOR
new ( STRING | @PARTS ) This is the default constructor. Depending on the number of arguments branches into new_from_string or new_from_parts. new_from_string ( STRING ) Interprets STRING as a SIP request or response and creates Net::SIP::Request or Net::SIP::Response object accordingly. Will die() if it cannot parse the string as a SIP packet. new_from_parts ( CODE|METHOD, TEXT|URI, \%HEADER|@HEADER, [ BODY ] ) If CODE|METHOD is numeric a Net::SIP::Response object will be created with the response code CODE and the text TEXT. Otherwise a Net::SIP::Request object will be created with the method METHOD and the uri URI. Header data can be given as a hash %HEADER or array @HEADER reference. In case of a hash the key is the SIP field name and the value as either a string or a @list of strings. The fields on the resulting SIP packet will be sorted by name of the fields and fields with multiple values will be created as seperat lines. If the header is given as an array the elements of the array are "[ key => value ]" pairs where the keys are the field names and the values are strings or @list of strings. Each pair will result in a single line in the SIP header. If the value was a list reference the values in the list will be concatened by ','. The order of the fields in the resulting SIP packet will be the same as in the array. The BODY is optional and can be given either as a string or as an reference to an object which has a method as_string, like Net::SIP::SDP. If the BODY is an object which has a method content_type it will set the "content-type" header of the SIP object based on the result of "BODY->content_type" unless a "content-type" header was explicitly given. METHODS
is_request Returns TRUE if the SIP packet is a request, otherwise FALSE. is_response Returns TRUE if the SIP packet is a response, otherwise FALSE. tid Returns a transaction ID created from the sequence number in the "CSeq" header and the "Call-Id" header. All packets with the same tid belong to the same transaction. cseq Returns "CSeq" header. Short for "$self->get_header( 'cseq' )". callid Returns "Call-Id" header. Short for "$self->get_header( 'call-id' )". get_header ( [ NAME ] ) If NAME is given it returns the SIP header for NAME. If no header exists returns (). If there is only one value for the header returns this value. In case of multiple values it returns a @list of all values, but if "wantarray" says, that the caller expects only a single value it will "croak()". If no NAME is given it will return a reference to a hash wich contains all fields and has the format described in new_from_parts. add_header ( NAME, VAL ) Adds the header at the end of the SIP header. VAL can be a string or a reference to a list of strings. insert_header ( NAME, VAL ) Like add_header, but the lines will be added on top of the header. del_header ( NAME ) Delete all lines from header where the field name is NAME. set_header ( NAME, VAL ) Replaces an existing header, like del_header followed by add_header. set_body ( VAL ) Sets body to VAL, which can be string or object. The handling for body objects see new_from_parts. as_string Returns string representation of SIP packet. dump ( [ LEVEL ] ) Returns dump of packet as string for debugging. The higher LEVEL is the more details one gets. At the moment a LEVEL of 0 gets a one- line summary and the rest the result from as_string. as_parts Returns Array with CODE|METHOD, TEXT|URI, @HEADER and BODY like used in new_from_parts. sdp_body Returns body as Net::SIP::SDP object if there is a body and the content-type is 'application/sdp' or empty. If body contains invalid SDP it raises an exception (e.g. die()). UNDOCUMENTED METHODS get_header_hashval ( [ NAME ] ) scan_header ( @ARG ) clone perl v5.14.2 2011-08-26 Net::SIP::Packet(3pm)
All times are GMT -4. The time now is 03:54 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy