Sponsored Content
Full Discussion: Extract lines from a file
Top Forums Shell Programming and Scripting Extract lines from a file Post 302968961 by chercheur111 on Wednesday 16th of March 2016 03:54:21 PM
Old 03-16-2016
Hi,
Please, with this code:
Code:
#! /bin/sh
{ read A; read B; printf "%s\n" $A $B; sort -r ; } < Versions.txt | awk -F\. 'T[$1,$2,$3]++'

and this file:

Code:
filename
-------------------------------------------------------
/tmp/g-85.n.gggg1000.fr-worker3.V.1.tar.bz2
/tmp/g-85.n.gggg1000.fr-worker2.V.2.tar.bz2
/tmp/g-85.n.gggg1000.fr-worker3.V.2.tar.bz2
/tmp/g-85.n.gggg1000.fr-worker1.V.1.tar.bz2
/tmp/g-85.n.gggg1000.fr-worker2.V.3.tar.bz2
/tmp/g-85.n.gggg1000.fr-worker2.V.1.tar.bz2
/tmp/g-85.n.gggg1000.fr-worker1.V.3.tar.bz2
/tmp/g-85.n.gggg1000.fr-worker1.V.2.tar.bz2
/tmp/g-85.n.gggg1000.fr-worker3.V.3.tar.bz2

I have this output
Code:
/tmp/g-85.n.gggg1000.fr-worker3.V.2.tar.bz2
/tmp/g-85.n.gggg1000.fr-worker3.V.1.tar.bz2
/tmp/g-85.n.gggg1000.fr-worker2.V.3.tar.bz2
/tmp/g-85.n.gggg1000.fr-worker2.V.2.tar.bz2
/tmp/g-85.n.gggg1000.fr-worker2.V.1.tar.bz2
/tmp/g-85.n.gggg1000.fr-worker1.V.3.tar.bz2
/tmp/g-85.n.gggg1000.fr-worker1.V.2.tar.bz2
/tmp/g-85.n.gggg1000.fr-worker1.V.1.tar.bz2

Please, how can i change the script to delete also the red lines ?

Thanks a lot for help.
Best reagards.

---------- Post updated at 02:54 PM ---------- Previous update was at 12:59 PM ----------

it works fine with:

Code:
#! /bin/sh
{ read A; read B; printf "%s\n" $A $B; sort -r ; } < Versions.txt | awk -F\. 'T[$1,$2,$3,$4]++'


Last edited by chercheur111; 03-16-2016 at 03:05 PM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

how to extract a range of lines from a file

I am reading a file that contains over 5000 lines and I want to assign it to a shell variable array (which has a restriction of 1024 rows). I had an idea that if I could grab 1000 record hunks of the file, and pipe the records out, that I could perform a loop until I got to the end and process 1000... (5 Replies)
Discussion started by: beilstwh
5 Replies

2. Shell Programming and Scripting

How to extract a sequence of n lines from a file

Hi I want to be able to extract a sequence of n lines from a file. ideas, commands and suggestions would be highly appreciated. Thanks (4 Replies)
Discussion started by: 0ktalmagik
4 Replies

3. Shell Programming and Scripting

Extract lines from a file automatically. Please a Help

hello, hope you can help me: ive got a file called archivos The content or structure of this file is ./chu0/filechu ./chu1/filechu I extract each line from this file manually and redirect to a file, and it Works fine, so the command line is: awk ‘/chu0/ {print $0}' < archivos >... (8 Replies)
Discussion started by: alexcol
8 Replies

4. Shell Programming and Scripting

extract particular lines from text file

I have two files file A which have a number in every row and file B which contains few hundred thousand rows with about 300 characters in each row (csv) What I need is to extract whole rows from B file (only these which numbers are indicated in A file) I also need to use cygwin. Any... (7 Replies)
Discussion started by: gunio
7 Replies

5. Shell Programming and Scripting

Extract the lines from input file

This is the sample input file b 05/Jul/2010:07:00:10 a 05/Jul/2010:06:00:10 b 05/Jul/2010:07:00:10 c 05/Jul/2010:07:10:10 d 05/Jul/2010:08:00:10 e 05/Jul/2010:09:00:10 f 05/Jul/2010:10:00:10 h 05/Jul/2010:11:00:10 i 05/Jul/2010:12:00:10 j ... (9 Replies)
Discussion started by: sandy1028
9 Replies

6. Shell Programming and Scripting

Extract some lines from one file and add those lines to current file

hi, i have two files. file1.sh echo "unix" echo "linux" file2.sh echo "unix linux forums" now the output i need is $./file2.sh unix linux forums (3 Replies)
Discussion started by: snreddy_gopu
3 Replies

7. Shell Programming and Scripting

Extract particular lines from a file

Hi all, I have a file with many records with information as given below ID A16L2_HUMAN Reviewed; 619 AA. AC Q8NAA4; A5PL30; B2RPK5; Q658V4; Q6PID3; Q8NBG0; DT 20-MAY-2008, integrated into UniProtKB/Swiss-Prot. DT 20-MAY-2008, sequence version 2. DT ... (1 Reply)
Discussion started by: kaav06
1 Replies

8. Shell Programming and Scripting

How to extract certain lines from a file?

Hi guys I have a several thousands line file in the following format: n817 -------------------------------------------------- n842 -------------------------------------------------- n877 -------------------------------------------------- n513 /bb/data/rmt2db.lrl:JBSKDB 31915 75... (4 Replies)
Discussion started by: aoussenko
4 Replies

9. Shell Programming and Scripting

Want to extract certain lines from big file

Hi All, I am trying to get some lines from a file i did it with while-do-loop. since the files are huge it is taking much time. now i want to make it faster. The requirement is the file will be having 1 million lines. The format is like below. ##transaction, , , ,blah, blah... (38 Replies)
Discussion started by: mad man
38 Replies

10. UNIX for Beginners Questions & Answers

Extract lines that have entries in VI file

Dears experts i have UNIX file that contain 4 million lines , i need to extract all lines that have entiries saved in VI file , i have below comand but it takes tooooo long time : for i in `cat file1.csv`; do cat dump | grep -i $i >> file2.csv; done where : file1.csv = VI file that... (12 Replies)
Discussion started by: is2_egypt
12 Replies
uuclean(8c)															       uuclean(8c)

Name
       uuclean - uucp spool directory clean-up

Syntax
       uuclean -p[pre] [ options ... ]

Description
       The  command  scans the spool directory for files with the specified prefix and deletes all those which are older than the specified number
       of hours.

       The -ppre argument causes the command to scan for files with pre as the file prefix.  You can specify up to 10 arguments.   A  without  any
       pre following causes all files older than the specified time to be deleted.  You must specify at least one argument.

Options
       -ntime	    Delete  all  files	whose age is more than time, in hours, (default is 72 hours) and that have the specified pre as their file
		    prefix.

       -m	    Send mail to the owner of the file when it is deleted.

       -ssystem     Delete files in all directories that are subdirectories of the per system spool directory that exists for system.  If  ALL	is
		    specified, then all system directories are processed.  ALL is the default.

       -ddirectory  Delete files that reside in the named directory.  The default directory is The option over rides the option.

       The  command typically starts the program.  In earlier versions, a deleted work file (C.file) would result in mail to the owner of the work
       file, regardless of the option.	Now, notification of deleted work files is sent to the user ID "uucp".	If the option  is  used,  mail	is
       also sent to the owner.

Examples
       Here are some example command lines:
       # uuclean -pLTMP. -pLOG. -n4 -d/usr/spool/uucp
       # uuclean -d/usr/spool/uucp/.XQTDIR -p -n
       # uuclean -smarkie -p -n84
       The third example deletes all files for the system that are older than 84 hours.

Files
       Directory with commands used by uuclean internally

See Also
       uucp(1c), uux(1c), cron(8)

																       uuclean(8c)
All times are GMT -4. The time now is 07:23 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy