removing particular lines ending with a .cnt extension in a text file


 
Thread Tools Search this Thread
Operating Systems Solaris removing particular lines ending with a .cnt extension in a text file
# 1  
Old 02-27-2008
removing particular lines ending with a .cnt extension in a text file

I have a text file with rows of information (it is basically a ls command information(o/p from ls command))
I need to remove the lines ending with a .cnt extension and keep the lines ending with .zip extension, how to accomplish this.
I also only need the date,size and name of the file from every row, i want to get rid of the permissions column at the first how do i accomplish this. any help is appreciated.


my file is a.txt its contents are
-rwx---rwx may 10 2007 236748629 d_lst_tst.cnt
-rwxrwxrwx may 12 2007 376864923 d_lst_tet.zip
-rwx-wx-wx may 12 2007 480527935 d_ink_let.cnt
----rwxrwx may 12 2007 367859629 f_ink_let.zip

I want to remove the first and third line from my text file and also want to remove the "rwx" part from the second and fourth lines how to do this.
# 2  
Old 03-03-2008
Try this:
Code:
# cat /tmp/tmp
-rwx---rwx may 10 2007 236748629 d_lst_tst.cnt
-rwxrwxrwx may 12 2007 376864923 d_lst_tet.zip
-rwx-wx-wx may 12 2007 480527935 d_ink_let.cnt
----rwxrwx may 12 2007 367859629 f_ink_let.zip
# grep -v \.cnt$ /tmp/tmp | cut -d' ' -f2-
may 12 2007 376864923 d_lst_tet.zip
may 12 2007 367859629 f_ink_let.zip

There is sure to be a way to do this in a single command, but I'm not really up to it at the moment Smilie
# 3  
Old 03-03-2008
Another way:

Code:
awk '/zip$/{print $2,$3,$4,$5}' file

Regards
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Removing PATTERN from txt without removing lines and general text formatting

Hi Everybody! First post! Totally noobie. I'm using the terminal to read a poorly formatted book. The text file contains, in the middle of paragraphs, hyphenation to split words that are supposed to be on multiple pages. It looks ve -- ry much like this. I was hoping to use grep -v " -- "... (5 Replies)
Discussion started by: AxeHandle
5 Replies

2. Shell Programming and Scripting

Removing md5sum lines stored in text file

Hello. I'm writing a script where every file you create will generate a md5sum and store it into a text file. Say I create 2 files, it'll look like this in the text file: d41d8cd98f00b204e9800998ecf8427e /helloworld/saystheman d41d8cd98f00b204e9800998ecf8427e /helloworld/test I... (3 Replies)
Discussion started by: batarangs_
3 Replies

3. Shell Programming and Scripting

Remove certain lines from file based on start of line except beginning and ending

Hi, I have multiple large files which consist of the below format: I am trying to write an awk or sed script to remove all occurrences of the 00 record except the first and remove all of the 80 records except the last one. Any help would be greatly appreciated. (10 Replies)
Discussion started by: nwalsh88
10 Replies

4. Shell Programming and Scripting

removing lines without text

How do I remove line that do not contain text, but that do contain tabs? I have tried the command cat file | awk NF but that doesn't work when the lines contain tabs (and spaces). I have also tried: cat file | sed '/^$/d' (9 Replies)
Discussion started by: locoroco
9 Replies

5. UNIX for Dummies Questions & Answers

Removing trailing lines at the end of a text file

How do you remove trailing empty lines at the end of a text file? Thanks! (3 Replies)
Discussion started by: evelibertine
3 Replies

6. Shell Programming and Scripting

removing a word in a multiple file starting at the dot extension

hi I would like to ask if someone knows a command or a script on how to rename a multiple file in the directory starting at the end of the filename or at the .extension( i would like to remove the last 11 character before the extension) for example Below is the result of my command ls inside... (5 Replies)
Discussion started by: jao_madn
5 Replies

7. UNIX for Dummies Questions & Answers

Removing prefix from multiple files and renaming file extension

Hello i have the files in this format pdb1i0t.ent pdb1lv7.ent pdb1pp6.ent pdb1tj2.ent pdb1xg2.ent pdb2b4b.ent pdb2ewe.ent Now i have to remove the prefix pdb from all the files and also i need to change the extension of .ent to .txt The new file should look like this ... (3 Replies)
Discussion started by: empyrean
3 Replies

8. Shell Programming and Scripting

Deleting lines ending with . from a file

HI I'm looking to delete lines ending with .tk from below data file --------- abc.tk mgm.tk dtk mgmstk ------ I have written below code ---- sed '/.tk *$/d' dat_file.txt > temp.txt ---- But its deleting all the lines ending with tk. I need to delete only the lines ending .tk my... (5 Replies)
Discussion started by: shekhar_v4
5 Replies

9. UNIX for Dummies Questions & Answers

removing multiple lines of text in a file

Hi, I'm trying to remove multiple lines of text based off a series of different words and output it to a new file The document contains a ton of data but i want to delete any line that has the following mx1.rr.biz.com or ns2.ri.biz.com i tried using grep -v filename "mx1.rr.biz.com" >... (3 Replies)
Discussion started by: spartan22
3 Replies

10. Shell Programming and Scripting

Removing lines in a text file.

Here is my problem I'm hoping you guru's can help me figure out. I have a text file that contains comma delimited columns. What I'm looking to do is see if the 24th column on each row in the file contains a value (not null), and then write/append that line to a different file. I've been... (4 Replies)
Discussion started by: WABonnett
4 Replies
Login or Register to Ask a Question