Delete Numbers, Spaces, Special Character from the begining of the line of a file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Delete Numbers, Spaces, Special Character from the begining of the line of a file
# 1  
Old 08-16-2014
Delete Numbers, Spaces, Special Character from the begining of the line of a file

Hi All,

I want to keep the name of the songs with their respective extensions only.

Sample Code
========

Code:
03 Choti choti gaiya choti choti gaval.mp3
03---Brazil Dhol.mp3
03 PAYALIYA .mp3
04 - Isq Risk [Funmaza.com].mp3
04%20-%20Oh%20My%20Love(wapking.in).mp3
08 - A2 - Aasan Nahin Yahan [DJMaza].mp3
AE NAZNEEN SUNO NA.MP3
[Songs.PK] 02 - Revival - Hum Tumhare Liye - Aye Sanam Aaj Yeh Quasam - Lata and Talat.mp3


Output should be :
============

Code:
Choti choti gaiya choti choti gaval.mp3
Brazil Dhol.mp3
PAYALIYA .mp3
Love.mp3
Aasan Nahin Yahan.mp3
AE NAZNEEN SUNO NA.MP3
Revival - Hum Tumhare Liye - Aye Sanam Aaj Yeh Quasam - Lata and Talat.mp3


Thanks in Advance.
Pramod

Last edited by Don Cragun; 08-16-2014 at 04:34 PM.. Reason: Added CODE tags for output.
# 2  
Old 08-16-2014
That is a very heterogeneous sample; I'm not sure that can be done in one go. Tried
Code:
sed -r 's/^.*[0-9]{2}[^[:alpha:]]*//; s/\([^)]*\)//; s/\[[^]]*\]//; s/ \././' file
Choti choti gaiya choti choti gaval.mp3
Brazil Dhol.mp3
PAYALIYA.mp3
Isq Risk.mp3
Love.mp3
A2 - Aasan Nahin Yahan.mp3
AE NAZNEEN SUNO NA.MP3
Revival - Hum Tumhare Liye - Aye Sanam Aaj Yeh Quasam - Lata and Talat.mp3

, but unsure how ro remove that A2 - without removing the Revival... piece
# 3  
Old 08-18-2014
A more appropriate response here is the "what have you tried so far?" one, IMO. O/P, pleas consider into which sub-forum you post. This doesn't belong in "How to Post in the Unix and Linux Forums". Moved.
# 4  
Old 08-18-2014
I suspect that this line:
Code:
04%20-%20Oh%20My%20Love(wapking.in).mp3

Should be
Code:
Oh My Love.mp3

In which case you want to replace %20 with space before the rest of RudiCs solution:

Code:
$ sed -r 's/%20/ /g; s/^.*[0-9]{2}[^[:alpha:]]*//; s/\([^)]*\)//; s/\[[^]]*\]//; s/ \././' infile
Choti choti gaiya choti choti gaval.mp3
Brazil Dhol.mp3
PAYALIYA.mp3
Isq Risk.mp3
Oh My Love.mp3
A2 - Aasan Nahin Yahan.mp3
AE NAZNEEN SUNO NA.MP3
Revival - Hum Tumhare Liye - Aye Sanam Aaj Yeh Quasam - Lata and Talat.mp3

Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Count specific character of a file in each line and delete this character in a specific position

I will appreciate if you help me here in this script in Solaris Enviroment. Scenario: i have 2 files : 1) /tmp/TRANSACTIONS_DAILY_20180730.txt: 201807300000000004 201807300000000005 201807300000000006 201807300000000007 201807300000000008 2)... (10 Replies)
Discussion started by: teokon90
10 Replies

2. Shell Programming and Scripting

parse special character in the line

Hi all, I have a file with some module names as below. Font::AFM Data::Grove ---> libxml-perl Net::LDAP ---> perl-ldap DBI XML .... ... .... and so on ... The file has some lines with the character " -->" . Now how can I cut only the last column of the line wherever "-->" is... (4 Replies)
Discussion started by: vijaya2006
4 Replies

3. Shell Programming and Scripting

Insert a special character $ in place of extra spaces

Hi Experts, I have called some.txt with the following content. oracle HYRDSRVIHUB01 pts/0 TESTIHUB 07-JUN-10 CREATE TABLE TESTIHUB PHONE ... (12 Replies)
Discussion started by: naree
12 Replies

4. UNIX for Dummies Questions & Answers

Command to delete numbers at beginning of txt file line

Hello. I have the following issue: my txt file has the following format: train/dr4/fklc0/sx175.txt 0 80282 Severe myopia contributed to Ron's inferiority complex. train/dr4/fklc0/sx355.txt 0 42906 Dolphins are intelligent marine mammals. train/dr4/fklc0/sa2.txt awk 'NR%2==0' test1.txt >... (4 Replies)
Discussion started by: li_bi
4 Replies

5. Shell Programming and Scripting

Delete rows based on line numbers in a file

I have to find the number of rows in a file and delete those many rows in another file. For example, if I have 3 rows in a file A, i have to delete first 3 rows in anothe file B, I have the code, it works as standalone, when I merge this with m application (c with unix), it doesnt work. ... (2 Replies)
Discussion started by: Muthuraj K
2 Replies

6. Shell Programming and Scripting

delete blank space in begining of line

Hi All, below is my data file file.txt $$0 ServerA LAN1 AAA IT01 04/30/2008 09:16:26 $$0 ServerB LAN1 AAA IT02 04/30/2008 09:16:26 here $ is a blank space how to delete first 2 blank spaces in a file. (4 Replies)
Discussion started by: karthikn7974
4 Replies

7. UNIX for Dummies Questions & Answers

[OpenServer 5]Line Printing and special character (é @)

Hello, On Sco OpenServer 5, i want to print using the lpr command, no CUPS installed. I print on an HP LaserJet 4050 on LAN (IP 192.168.x.x) the printer is installed by HP Network Printer service. it works fine, but Specials characters, like é, @ or ° print bad characters. Is there... (5 Replies)
Discussion started by: tankd
5 Replies

8. Shell Programming and Scripting

delete a special character in file

hi i want to delete a particular character in file. example file name:abcsample abc=bbbqw3/ hidh=ajjqiwio4/ xyx=hakjp/ ........../ ......./ i want to delete that special character (/) in abcsample file Permnently.please give the required commands for my requirement. required... (1 Reply)
Discussion started by: srivsn
1 Replies

9. Shell Programming and Scripting

delete a special character in file

hi i want to delete a particular character in file. example file name:abcsample abc=bbbqw3/ hidh=ajjqiwio4/ xyx=hakjp/ ........../ ......./ i want to delete that special character (/) in abcsample file.please give the required commands for my requirement. thank you (3 Replies)
Discussion started by: srivsn
3 Replies
Login or Register to Ask a Question