Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

request translation of perl code line

Posted on 2013-12-12
2
Medium Priority
?
283 Views
Last Modified: 2013-12-13
Greetings,
I am not a perl expert by any means.
I have this line of code that reads lines in a file:

%s fs -cat %s | perl -pe 's/\t/,/g' > %s

I want to say that -pe and the string behind it talks about delimiters?

If I wanted to write this line twice, once with tab-only and once with comma-only delimiters,
how do I do it?
Thanks
0
Comment
Question by:Evan Cutler
2 Comments
 
LVL 85

Accepted Solution

by:
ozo earned 2000 total points
ID: 39715572
perl -MO=Deparse  -pe 's/\t/,/g'
LINE: while (defined($_ = <ARGV>)) {
    s/\t/,/g;
}
continue {
    die "-p destination: $!\n" unless print $_;
}

s/\t/,/g  Searches for tab and replaces it with , /g means match globally, i.e., find all occurrences.

If instead you want to change , to tab, you can do s/,/\t/g
0
 
LVL 9

Author Closing Comment

by:Evan Cutler
ID: 39717551
Thanks much.
This got me where I needed to go.

Most appreciated.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Setting up Secure Ubuntu server on VMware 1.      Insert the Ubuntu Server distribution CD or attach the ISO of the CD which is in the “Datastore”. Note that it is important to install the x64 edition on servers, not the X86 editions. 2.      Power on th…
It’s 2016. Password authentication should be dead — or at least close to dying. But, unfortunately, it has not traversed Quagga stage yet. Using password authentication is like laundering hotel guest linens with a washboard — it’s Passé.
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses

972 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question