Unix perl scripting


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Unix perl scripting
# 1  
Old 05-10-2012
Unix perl scripting

Hi ,

Could someone please help me for following script:
Code:
perl -pi -e 's/\"//g' ${FILELIKE}*.csv
perl -pi -e '$_ ="" if ($.==1);' ${FILELIKE}*.csv

What these 2 commands are doing?

Thanks,
Preetpal

Moderator's Comments:
Mod Comment How to use code tags

Last edited by Franklin52; 05-10-2012 at 06:38 AM.. Reason: Please use code tags
# 2  
Old 05-10-2012
Code:
 
 
#Replace all the "(double quotes) to none in all csv files
 
perl -pi -e 's/\"//g' ${FILELIKE}*.csv
 
# delete the first line in all the csv files.
perl -pi -e '$_ ="" if ($.==1);' ${FILELIKE}*.csv

# 3  
Old 05-10-2012
Sorry to ask you these questions but i am a beginner in this.

1.what does -pi and -e stands for?
2. What does 's/\"//g' stands for?
3.What does '$_ ="" if ($.==1);' stands for?
# 4  
Old 05-10-2012
1) -p is print all lines by default.
-i is inplace editing of file. So whatever changes you make would be written in file. A safer way is to use "-i.bak" as in perl -pi.bak -e .... so that you have a backup of the original file.

2) s/\"//g --> All instances of double-quotes are deleted (or rather substituted with null)

3) $_ ="" if ($.==1) --> $. refers to line number. If first line is being read, then replace the contents of first line with nothing.

4) And please learn how to use code tags.
# 5  
Old 05-10-2012
Thanks a lot balajesuri
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need help on PERL scripting

Hi Guys; Im pretty new here in the forum and I need help on how to write a PERL script. Basically I have a file with content like these AAAAAAAAAAAAAAAAAAAAAAAAAAA BBBBBBBBBBBBBBBBBBBBBBBBBBBBBB CCCCCCCCCCCCCCCCCCCCCCCCCCC DDDDDDDDDDDDDDDDDDDDDDDDDDD EEEEEEEEEEEEEEEEEEEEEEEEEEEEEE... (5 Replies)
Discussion started by: ahock
5 Replies

2. Web Development

Perl scripting or shell scripting?

i am going to study any one of the scripting languages mentioned above(shell 0r perl scripting) . Which is having more scope for a fresher? (1 Reply)
Discussion started by: Anna Hussie
1 Replies

3. Shell Programming and Scripting

Know unix scripting somewhat ,now how to add perl to my skillset.

Hi All, I have learned a bit of unix scripting since i have been working on it for the past 2 months. I would like to add perl to my skills. I have read the O'reillys Learning perl book. Can someone suggest how to use this forum for facing newer challenges on a daily basis starting with the... (1 Reply)
Discussion started by: kunwar
1 Replies

4. What is on Your Mind?

Shell Scripting vs Perl scripting

Gents, I have been working in a Solaris/Unix environment for about 9 months. I took some linux classses online before getting the job. But, I am not very good at scripting. I want to learn how to script. Do you think that I should start with Shell scripting or Perl? I wanted to continue with... (2 Replies)
Discussion started by: Pouchie1
2 Replies

5. What is on Your Mind?

Shell scripting vs Perl scripting

Hi all, I would like to start developping some good scripting skills. Do you think it would be best to start with shell scripting or Perl? I already got a fundation, really basics, in perl. but I am wondering what would be best to be good at first. Can you please help me determine which one to... (14 Replies)
Discussion started by: Pouchie1
14 Replies

6. Shell Programming and Scripting

Linux/Unix shell scripting vs Perl

Hi, I have general question: i have good working Perl script with .pl extension, and now I have to migrate all to another Linux box, and I was told that I can use only shell scripting, so I'm not sure how different those two things are, will it work without any changes . Is there anything smart I... (6 Replies)
Discussion started by: trento17
6 Replies

7. UNIX for Dummies Questions & Answers

Need help configuring Active Perl on Windows Vista.: Perl Scripting on Windows

Hi All, Need help configuring Active Perl on Windows Vista. I am trying to install Active Perl on Windows Vista. The version of Active Perl i am trying to install is : ActivePerl 5.10.1 Build 1006 After installing it through cmd, When i try to run perl -v to check the version, i get the... (2 Replies)
Discussion started by: Vabiosis
2 Replies

8. Shell Programming and Scripting

Call Shell scripting from Perl Scripting.

Hi How to call a shell scripting through a Perl scripting? Actually I need some value from Shell scripting and passes in the Perl scripting. So how can i do this? (2 Replies)
Discussion started by: anupdas
2 Replies

9. Shell Programming and Scripting

Help with perl scripting

Hi All, I need to run smartctl using nagios account but I'm not familiar with perl scripting. The existing script runs smartctl using root account. I need it to run using nagios to eliminate security risks. #!/usr/bin/perl -w # checks for possible disk errors use strict; my... (3 Replies)
Discussion started by: linuxgeek
3 Replies

10. Shell Programming and Scripting

Need help in perl scripting.

Hi, To run a perl script i am giving command like this in DOS prompt d:> perl D:\<dir_name>\<dir_name>\sample.pl Its throwing the following error while running the above syntax error at <eval 4> line 1, near "use D:" Can anyone help? (3 Replies)
Discussion started by: mvictorvijayan
3 Replies
Login or Register to Ask a Question