LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-04-2023, 04:30 PM   #16
GPGAgent
Senior Member
 
Registered: Oct 2018
Location: Surrey UK
Distribution: Mint 20 xfce 64bit
Posts: 1,026

Original Poster
Blog Entries: 3

Rep: Reputation: 133Reputation: 133

Quote:
Originally Posted by MadeInGermany View Post
That is because by default $_ ends with a newline character, and print does not print an ending newline character.
You can change both behaviors with the -l option.
Code:
ls *.ts | perl -lne 'print "\"file $_\""'
Where I think it makes more sense to put the escaped quotes around the $_

In fact perl -lne has the most in common with awk. Even BEGIN and END sections work if you wrap the main/loop section in braces.
Perfect
Code:
/TEST$ ls *.ts | perl -lne 'print "\"file $_\""'
"file 167275.ts"
"file 361879.ts"
"file 445115.ts"
"file 462757.ts"
"file 514423.ts"
"file 612203.ts"
"file 617537.ts"
"file 654815.ts"
"file 725775.ts"
"file 759838.ts"
"file 844680.ts"
"file 942393.ts"
thanks everyone
 
  


Reply

Tags
perl



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Need help understanding this Perl syntax new_user3085 Programming 5 09-26-2018 11:07 AM
Starting httpd: httpd: Syntax error on line 209 of /etc/httpd/conf/httpd.conf: Syntax sethukpathi Linux - Networking 6 04-12-2008 11:26 AM
Need help with wild card syntax to semi-automate file conversion using a perl script kmkocot Linux - Newbie 5 12-12-2007 01:55 PM
C++ syntax error before :: token HELP, i cant find the syntax error :( qwijibow Programming 2 12-14-2004 06:09 PM
perl(Cwd) perl(File::Basename) perl(File::Copy) perl(strict)....What are those? Baldorg Linux - Software 1 11-09-2003 08:09 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:08 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration