Command to delete numbers at beginning of txt file line


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Command to delete numbers at beginning of txt file line
# 1  
Old 01-25-2010
Bug Command to delete numbers at beginning of txt file line

Hello. I have the following issue: my txt file has the following format:
Code:
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

Code:
awk 'NR%2==0' test1.txt > test2.txt


I managed to eliminate the first , third and sentence. I don't know what command to use to eliminate the numbers at the beginning of each line and put it in another output file. Any suggestion is more than welcomed.

Thank you very much
# 2  
Old 01-25-2010
Code:
awk 'NR%2==0 { sub($1 FS"+",""); print } ' test1 > test2

# 3  
Old 01-25-2010
Bug

Thank you for the reply Smilie. There is one slight issue left. With your command I got rid of the first, third and fifth line and also from the first number ( 0 ). I am a "very" beginner and this is why I am asking.
80282 Severe myopia contributed to Ron's inferiority complex.
42906 Dolphins are intelligent marine mammals.
44544 Don't ask me to carry an oily rag like that.

Code:
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
0 44544 Don't ask me to carry an oily rag like that.

but I still have the others. This is my outpur in test2.txt:

Code:
80282 Severe myopia contributed to Ron's inferiority complex.
42906 Dolphins are intelligent marine mammals.
44544 Don't ask me to carry an oily rag like that.

# 4  
Old 01-25-2010
Code:
awk 'NR%2==0 { sub($1 FS"+"$2 FS"+",""); print } ' file

# 5  
Old 01-25-2010
MySQL

Thank you sooooo much. You saved me Smilie. I appreciate your help and timeSmilie
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Read in txt file and run a different command for each line

hi, i'm trying to write a tcsh script that reads in a text file (one column) and the runs a different command for each line of text. i've found lots of example commands for bash, but not for tcsh. can anyone give me a hint? thanks, jill (8 Replies)
Discussion started by: giuinha
8 Replies

2. UNIX for Dummies Questions & Answers

Split Every Line In Txt Into Separate Txt File, Named Same As The Line

Hi All Is there a way to export every line into new txt file where by the title of each txt output are same as the line ? I have this txt files containing names: Kandra Vanhooser Rhona Menefee Reynaldo Hutt Houston Rafferty Charmaine Lord Albertine Poucher Juana Maes Mitch Lobel... (2 Replies)
Discussion started by: Nexeu
2 Replies

3. Shell Programming and Scripting

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 ======== 03 Choti choti gaiya choti choti gaval.mp3 03---Brazil Dhol.mp3 03 PAYALIYA .mp3 04 - Isq Risk .mp3 04%20-%20Oh%20My%20Love(wapking.in).mp3 08 - A2 - Aasan Nahin Yahan .mp3 AE... (3 Replies)
Discussion started by: Pramod_009
3 Replies

4. UNIX for Dummies Questions & Answers

Script to delete files line by line in .txt document

Friends, I am in need to delete files from a directory on a regular basis. I want to place all the files to be deleted in delete .txt file and require a script to delete files, line by line from this delete.txt file. Please help me with this script as am new to unix scripting. (3 Replies)
Discussion started by: fop4658
3 Replies

5. Shell Programming and Scripting

Need to append the date | abcddate.txt to the first line of my txt file

I want to add/append the info in the following format to my.txt file. 20130702|abcd20130702.txt FN|SN|DOB I tried the below script but it throws me some exceptions. <#!/bin/sh dt = date '+%y%m%d'members; echo $dt+|+members+$dt; /usr/bin/awk -f BEGIN { FS="|"; OFS="|"; } { print... (6 Replies)
Discussion started by: harik1982
6 Replies

6. Shell Programming and Scripting

Repeat command with new variable for each line in txt file

Well here is my question. Let's say I have this Script: find /var/mobile/ maxdepth -2 name "$x" >> /"$x".txt The thing is I want to repeat this script and pull out a variable from a text file like this (each line = new variable $x and another run of the whole command) Thanks for... (27 Replies)
Discussion started by: pasc
27 Replies

7. Shell Programming and Scripting

Delete lines with line numbers.

Hi, I have a file will 1000 lines.... I want to deleted some line in the file... like 800-850 lines i want to remove in that... can somebody help me..? thanks. (2 Replies)
Discussion started by: Kattoor
2 Replies

8. Shell Programming and Scripting

Command to remove numbers from beginning of txt file

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 With the... (1 Reply)
Discussion started by: li_bi
1 Replies

9. Shell Programming and Scripting

How to fetch rows based on line numbers or based on the beginning of a word?

I have a file which will have rows like shown below, ST*820*316054716 RMR*IV*11333331009*PO*40.31 REF*IV*22234441009*xsss471-2762 DTM*003*091016 ENT*000006 RMR*IV*2222234444*PO*239.91 REF*IV*1234445451009*LJhjlkhkj471-2762 </SPAN> DTM*003* 091016 RMR*IV*2223344441009*PO*40.31... (18 Replies)
Discussion started by: Muthuraj K
18 Replies

10. 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
Login or Register to Ask a Question