Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
09-21-2003, 10:41 PM
|
#1
|
LQ Newbie
Registered: Aug 2003
Distribution: RH9
Posts: 4
Rep:
|
deleting characters at the beginning of a line
im not sure if this is the place for this, but oh well. here is what im trying to do. i have a list that is in this format:
(423) smokeywrz
(407) Wonderbox
(359) Dark Sian
(347) ScorpioNinja
im trying to delete everything in the parentheses (and the parentheses themselves) so im left with just the names. is there a command that i can use to delete the first few characters in every line? i tried tr and sed, but i failed. basically, im just really confused 
|
|
|
09-22-2003, 12:27 AM
|
#2
|
LQ Guru
Registered: Mar 2002
Location: Salt Lake City, UT - USA
Distribution: Gentoo ; LFS ; Kubuntu ; CentOS ; Raspbian
Posts: 12,613
Rep:
|
You can try with cut, but YMMV with your understanding. I believe this might live better in "programming", however I'll leave it up to you whether it gets moved or not (simply reply with your request).
Cool
|
|
|
09-22-2003, 07:33 PM
|
#3
|
LQ Newbie
Registered: Aug 2003
Distribution: RH9
Posts: 4
Original Poster
Rep:
|
yeah, that would be cool if you moved it. i tried with cut, but it always says this:
cut: invalid byte, character or field list
Try `cut --help' for more information.
im not sure the syntax, even though it says in the man pages. if i wanna remove (423) and stuff like it, i would use (*) right? but im not sure how to do that, and i tried as many combinations of things i could. thanks.
|
|
|
09-22-2003, 11:24 PM
|
#4
|
LQ Guru
Registered: Mar 2002
Location: Salt Lake City, UT - USA
Distribution: Gentoo ; LFS ; Kubuntu ; CentOS ; Raspbian
Posts: 12,613
Rep:
|
Cool:
Moving to Programming
|
|
|
09-23-2003, 01:03 AM
|
#5
|
Member
Registered: Aug 2003
Location: Suprisingly in Heaven
Posts: 223
Rep:
|
cat file | awk 'BEGIN{FS=")"}{print $2}'
|
|
|
09-23-2003, 01:36 AM
|
#6
|
Member
Registered: Aug 2003
Location: Suprisingly in Heaven
Posts: 223
Rep:
|
Quote:
Originally posted by poobeany
yeah, that would be cool if you moved it. i tried with cut, but it always says this:
cut: invalid byte, character or field list
Try `cut --help' for more information.
im not sure the syntax, even though it says in the man pages. if i wanna remove (423) and stuff like it, i would use (*) right? but im not sure how to do that, and i tried as many combinations of things i could. thanks.
|
cat file | cut -d ")" -f2
THis works fine
|
|
|
09-23-2003, 05:17 PM
|
#7
|
LQ Newbie
Registered: Aug 2003
Distribution: RH9
Posts: 4
Original Poster
Rep:
|
thanks a ton guys
|
|
|
All times are GMT -5. The time now is 01:26 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|