Linux - NewbieThis 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
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.
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.
2005-12-15+19:16:32.0000000000 /mnt/main//GUNxSWORD(Music)/13 Bitter Dream
2005-12-15+19:16:32.0000000000 /mnt/maerawerawer/GUNxSWO RD(Music)/12 Hearts Together
I wish to use sed to replace the long string of numbers in the front. Such that:
Code:
/mnt/main//GUNxSWORD(Music)/13 Bitter Dream
/mnt/maerawerawer/GUNxSWO RD(Music)/12 Hearts Together
are the results, this seems like that I only want to match the first space and don't want the match to get the 2nd or spaces after words.
I've tried:
sed 's:^.*\s::i'
but it doesnt work.
Thanks,
Ted
The regular expression .*\s matches all the characters until the last space (spaces included). You have to exclude the space from the character list in order to match all the chracters until the first space, e.g.
Code:
sed 's/^[^ ]* //' file
Not sure about matching only the first space and not the second one. According to the desired output you should match any number of spaces after the first string, that is
thanks for everyone's help here. colucix's first code seems to got me very close:
Code:
2003-09-29+08:39:08.0000000000 /mnt/main/media/music/主題曲/灌籃少年/Dear Boys OST - Love & Chasing/04 - Seishun In the Starlight.mp3
2003-09-29+08:29:12.0000000000 /mnt/main/media/music/主題曲/灌籃少年/Dear Boys OST - Love & Chasing/02 - Go Go Goal.mp3
2003-09-29+08:08:50.0000000000 /mnt/main/media/music/主題曲/灌籃少年/Dear Boys OST - Love & Chasing/03 - Promise.mp3
2003-09-29+08:07:28.0000000000 /mnt/main/media/music/主題曲/灌籃少年/Dear Boys OST - Love & Chasing/05 - Love and Chasing.mp3
2000-06-13+18:26:45.2655000000 /mnt/main/media/music/英文歌/how do i breathe.mp3
gave me
Code:
Boys OST - Love & Chasing/01 - Shake It Up.mp3
Boys OST - Love & Chasing/04 - Seishun In the Starlight.mp3
Boys OST - Love & Chasing/02 - Go Go Goal.mp3
Boys OST - Love & Chasing/03 - Promise.mp3
Boys OST - Love & Chasing/05 - Love and Chasing.mp3
do i breathe.mp3
but I wish to get the space prior toe that:
Code:
/mnt/main/media/music/主題曲/灌籃少年/Dear Boys OST - Love & Chasing/04 - Seishun In the Starlight.mp3
/mnt/main/media/music/主題曲/灌籃少年/Dear Boys OST - Love & Chasing/02 - Go Go Goal.mp3
/mnt/main/media/music/主題曲/灌籃少年/Dear Boys OST - Love & Chasing/03 - Promise.mp3
/mnt/main/media/music/主題曲/灌籃少年/Dear Boys OST - Love & Chasing/05 - Love and Chasing.mp3
/mnt/main/media/music/英文歌/how do i breathe.mp3
2003-09-29+08:39:08.0000000000 /mnt/main/media/music/主題曲/灌籃少年/Dear Boys OST - Love & Chasing/04 - Seishun In the Starlight.mp3
2003-09-29+08:29:12.0000000000 /mnt/main/media/music/主題曲/灌籃少年/Dear Boys OST - Love & Chasing/02 - Go Go Goal.mp3
2003-09-29+08:08:50.0000000000 /mnt/main/media/music/主題曲/灌籃少年/Dear Boys OST - Love & Chasing/03 - Promise.mp3
2003-09-29+08:07:28.0000000000 /mnt/main/media/music/主題曲/灌籃少年/Dear Boys OST - Love & Chasing/05 - Love and Chasing.mp3
2000-06-13+18:26:45.2655000000 /mnt/main/media/music/英文歌/how do i breathe.mp3
is not a space but a tab /t thus:
sed 's:^.*\t::g'
simply did the trick, but thanks!
Ted
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.