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 - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 03-05-2003, 11:06 AM   #1
armegeden
LQ Newbie
 
Registered: Jan 2003
Posts: 6

Rep: Reputation: 0
Question using "cut" in perl script


simple question; i'm using cut in a perl script to get the comment field and home directory field out of the /etc/passwd file. when i do this and store the results in variables, a newline is stuck on the end of them. this in turn makes the useradd command unhappy when i specify them in the arguments list. ie: useradd -c $name -d $home. how do i get the trailing newline character out of those variables?


thanks,
jasonp
 
Old 03-05-2003, 11:08 AM   #2
cnjohnson
Member
 
Registered: Nov 2002
Location: Nashville
Distribution: FreeBSD, Linux, OS-X
Posts: 544

Rep: Reputation: 30
Look at chomp

Cheers--
Charles
 
Old 03-05-2003, 11:08 AM   #3
m0rl0ck
Member
 
Registered: Nov 2002
Distribution: A totally 133t distro :)
Posts: 358

Rep: Reputation: 31
man perlfunc
see chomp
 
Old 03-06-2003, 09:09 AM   #4
armegeden
LQ Newbie
 
Registered: Jan 2003
Posts: 6

Original Poster
Rep: Reputation: 0
indeed

lol, thanks guys! that took care of it. the chomp function was already used elsewhere in the script, i just never realized what it did. another guy wrote it in perl, and my perl knowledge has been gotten from working on that script a little. time to buy me a book! :P 'preciate it!


jasonp
 
  


Reply



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
bash script: using "select" to show multi-word options? (like "option 1"/"o zidane_tribal Programming 7 12-19-2015 01:03 AM
problem "make"ing gtk+ "/usr/bin/env: perl -w" caid Linux - Newbie 8 07-29-2005 04:51 AM
Can't install "glibmm" library. "configure" script can't find "sigc++-2.0&q kornerr Linux - General 4 05-10-2005 02:32 PM
Compiling KDE 3.2.0 - "Can't open perl script "/dcopidlng/kalyptus" linuxgamer09483 Linux - Software 3 04-09-2004 08:25 PM
LFS 4.1: Stalled at Perl, "missing seperator" error from "make" SparceMatrix Linux From Scratch 1 06-07-2003 03:31 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 03:25 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