can you explain this perl command?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting can you explain this perl command?
# 1  
Old 12-24-2011
can you explain this perl command?

I am using this line of perl code to change the file format and remove ^M at the end of each line in files:

Code:
perl -i -pe's/\r$//;' <name of file here>

Can you explain to me what this code does, and translate it into bash/awk/sed?
# 2  
Old 12-24-2011
you won't need code to remove ^M in a file... just use
Code:
dos2unix filewith^M newfile

# 3  
Old 12-24-2011
Or open the file in vi and do this: :%s/<ctrl+v+m>//g
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Perl/Array Sorting : Can someone please explain below code $h{$_}++

sub uniq { my %h; return grep { !$h{$_}++ } @_ } The above code is to remove duplicates from array. I am having hard time understanding below things (basically around highlighted code in bold)- when was the value inserted in hash? and are we only adding a key in Hash not... (1 Reply)
Discussion started by: Tanu
1 Replies

2. Red Hat

Please help to explain the command

su - keibatch -c ""date ; /usr/local/kei/batch/apb/bin/JKEIKYK4140.sh -run "&$C$6&" WSUKE100201"" Not clear about : date ; /usr/local/kei/batch/apb/bin/JKEIKYK4140.sh -run "&$C$6&" WSUKE100201 Please help (2 Replies)
Discussion started by: honda_city
2 Replies

3. UNIX for Dummies Questions & Answers

Please explain this command?

Hi, I saw this. But I don't know why we need this? ls mydir > foo.txt ## I know what this will do, it will take the results and write to the file called foo.txt ls mydir > foo.txt 2>&1 ## Don't know why we need 2>&1 Thanks. (2 Replies)
Discussion started by: samnyc
2 Replies

4. UNIX for Dummies Questions & Answers

Explain perl formatting commands

Could you please tell the meaning of Below mentioned perl script lines: format OWNER_TOTAL = @< Owner Code @<<<<<<total: @#######.## @#######.## @#######.## @#######.## @#######.## @#######.## @#######.## @#######.## @#######.## @#######.## @###### #.## $prev_cust_type, $prev_owner_code,... (2 Replies)
Discussion started by: vinothrajan55
2 Replies

5. Shell Programming and Scripting

Can someone please explain what tr#A-Za-z0-9+/# -_#; means in perl?

Can someone please explain what tr#A-Za-z0-9+/# -_#; means in perl? (4 Replies)
Discussion started by: 3junior
4 Replies

6. Shell Programming and Scripting

perl: Please explain this for me: $hexdigit = (0 .. 9, 'a' .. 'f')[$num & 15];

This is taken from perlop. I can't understand what's going on, please can someone explain this for me? $hexdigit = (0 .. 9, 'a' .. 'f'); to get a hexadecimal digit (2 Replies)
Discussion started by: ksheller
2 Replies

7. UNIX for Advanced & Expert Users

perl explain syntax !!!

hi all i was going through some perl code i came across this line and i am not getting what is exactly going on .. $$this{localtion} = GetName->GetVarName("EXE_DIR") ; what is the red part doing in above code (2 Replies)
Discussion started by: zedex
2 Replies

8. UNIX for Dummies Questions & Answers

Can anyone explain what this command is doing?

Specifically what is the purpose of sed? What is f? Why is the 'cp f $phonefile' line needed when the script ‘goes live'? Why might that two commands following sed be commented out at the present time ( i.e., during development)? Thanks in... (2 Replies)
Discussion started by: knp808
2 Replies

9. Shell Programming and Scripting

please explain the command

Hi all , please explain the following command : perl -e 'select(undef,undef,undef,.15)' Thanks and Regards Navatha (2 Replies)
Discussion started by: Navatha
2 Replies

10. Shell Programming and Scripting

perl doubt plz explain....

hi all i wrote a shell script which uses perl script my code is : >cat filename | while read i >do >perl -e 'require "/home/scripts/abc.pl" ; abc("$i")' >done perl script used will simply check syntax of Cobol programs but it didn't work for me so i asked my colleague he suggested... (1 Reply)
Discussion started by: zedex
1 Replies
Login or Register to Ask a Question