Clean file in single action


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Clean file in single action
# 1  
Old 06-19-2006
Clean file in single action

What one finds challenging another finds simple...

(HPUX B.11.11)

I have a text file named something like 12345.dst that could look like this:

DOG
CAT
NONE
TEST
CAT


What I want to end up with is 12345.dst looking like this:

CAT
DOG
TEST


removing "NONE" should it be there and doing the equivalent of "sort -u" on the remains. I know how to get out the "NONE" in a one-liner:

/bin/echo "g/^NONE$/d\nwq!" | ex -s 12345.dst

Is there a way to add in the functional equivalent of a "sort -u" to this command line?

Thanks!
# 2  
Old 06-19-2006
Have you thought about:

grep -v -w NONE 12345.dst |sort -u
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Compare file name and take action

Have some files in /tmp/dir abc.zip 123.zip 345.zip and if name matches to 345.zip then take action My code.... am i doing something wrong ? Please advise. #!/bin/bash set -x cd /tmp/dir for i in *.* do if ] then (4 Replies)
Discussion started by: abhaydas
4 Replies

2. Shell Programming and Scripting

Take action only if a file is X hours (or seconds) old

shell: #!/bin/ash I searched and found a few relevant posts (here and here - both by porter, on the same day (?)) however both are just a do while loop, I need to check a file date and compare it to the current time. I would like it to say if file 'test' is more than 12 hours old than "right... (3 Replies)
Discussion started by: phdeez
3 Replies

3. Shell Programming and Scripting

Opening file and executing an action

I want the script to read the directory I am running the script from and print the contents of any file that has GX in it's title. This is the code needed. But how do I combine it? #!/usr/bin/perl opendir(CURRENT,"."); @list = readdir(CURRENT); closedir(CURRENT); foreach $item (@list){... (4 Replies)
Discussion started by: DemonixX
4 Replies

4. Shell Programming and Scripting

Take action if a particular file appears in a directory

This is my task - pls help Write a script that will run every 5 min and check if a particular file has appeared in a particular directory. Once it appears then rename the file and move it a bkp directory and run another script. (3 Replies)
Discussion started by: mrudula009
3 Replies

5. UNIX for Dummies Questions & Answers

command to clean up file systems

As you will verify, I am a really naive user of AIX 5.1. As such I wonder if you could possibly let me know of a command or procedure I could use to automatically, globally and safely, remove all useless files from my machine. I'm not referring to my own files because I perfectly know which of them... (1 Reply)
Discussion started by: ahjchr
1 Replies

6. UNIX for Advanced & Expert Users

Unable to clean up file system

Hi, Has anyone ever encountered the following scenario: I am working on a SUN server with solaris 10 installed and veritas managing the filesystem. One of the file systems has become full: df -kh /ossrc/dbdumps Filesystem size used avail capacity Mounted on... (6 Replies)
Discussion started by: eeidel
6 Replies

7. UNIX for Dummies Questions & Answers

Clean directories by reading from file

I have a file in following format directory1=/out/log purgedays1=4 extn1=log,out,txt directory2=/clean/log purgedays2=4 extn2=log,out now i need need to create a script that reads this file and cleans all the files with the given extn from the given directory. The catch here is that... (2 Replies)
Discussion started by: max_payne1234
2 Replies

8. UNIX for Advanced & Expert Users

Clean File

BeginDate 07/01/06 End: 07/31/06 Cust: A02991 - Burnham 0002000 5,829,773 145.3 0009701 4,043,850 267.3 2005000 286,785.13 100.0 BeginDate 07/01/06 End: 07/31/06 Cust: A01239 - East Track PSE Index A 0009902 317,356.82 890.2 0020021 ... (5 Replies)
Discussion started by: kris01752
5 Replies

9. UNIX for Advanced & Expert Users

Clean Text File

HI, I have a file which comes from crystal reports in the below format. I need to clean the file so that i will only have the columns(deptid,empid,ename,sal) and the data below the column names. There is a bug in the repoting tool( we only see page1-1 for every department).The rundate change... (1 Reply)
Discussion started by: kris01752
1 Replies

10. UNIX for Dummies Questions & Answers

make and clean in a single rule in the makefile.

Hi, This stems from the following thread https://www.unix.com/showthread.php?t=18299 I have a makefile which makes either executables or a shared library. i.e. make -f unix.mak will create the executables and make -f unix.mak libolsv will create the shared library. Since these have to be... (4 Replies)
Discussion started by: vino
4 Replies
Login or Register to Ask a Question