Find and list script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Find and list script
# 1  
Old 02-19-2011
Find and list script

Hello All,
ksh script.

Please consider the following case .

Code:
[/bz/arch]$ ls -l
-rw-r----- 1 100 400  405143552 Mar 21  2010 bz_1_0000063547_561428818.arc
-rw-r----- 1 100 400  404148224 Feb 19 09:55 bz_1_0000079359_561428818.arc
-rw-r----- 1 100 400  405625856 Feb 19 14:30 bz_1_0000079360_561428818.arc
-rw-r----- 1 100 400  404066304 Feb 19 18:11 bz_1_0000079361_561428818.arc
-rw-r----- 1 100 400  404066304 Feb 19 18:11 bz_1_0000079362_561428818.arc
-rw-r----- 1 100 400  404467712 Feb 19 18:42 bz_1_0000079363_561428818.arc
-rw-r----- 1 100 400  404066304 Feb 19 18:42 bz_1_0000079364_561428818.arc
-rw-r----- 1 100 400  404066304 Feb 19 18:52 bz_1_0000079365_561428818.arc
-rw-r----- 1 100 400  404467712 Feb 19 18:55 bz_1_0000079366_561428818.arc

I am getting as parameter a name of the of file with ".arc" extention.
I need to disply the list of the files (ls -l) from this file until the end of the list.
For example if i am getting as an input the file : bz_1_0000079362_561428818.arc ,
then i need to list the rest of the file list (including this file).
In this case the output should be :

Code:
-rw-r----- 1 100 400  404066304 Feb 19 18:11 bz_1_0000079362_561428818.arc
-rw-r----- 1 100 400  404467712 Feb 19 18:42 bz_1_0000079363_561428818.arc
-rw-r----- 1 100 400  404066304 Feb 19 18:42 bz_1_0000079364_561428818.arc
-rw-r----- 1 100 400  404066304 Feb 19 18:52 bz_1_0000079365_561428818.arc
-rw-r----- 1 100 400  404467712 Feb 19 18:55 bz_1_0000079366_561428818.arc

Thanks

Last edited by pludi; 02-19-2011 at 02:09 PM.. Reason: code tags, please...
# 2  
Old 02-19-2011
sed
Code:
F="bz_1_0000079362_561428818.arc"
ls -l | sed -n "/.*$F/,\$p"

# 3  
Old 02-20-2011
Code:
sed -n "/$F/,\$p" infile

Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script to find Error: rpmdb open failed on list of servers

Hello all, I have a task to patch red hat servers and some servers have a corrupted rpm database and return the error: Error: rpmdb open failed I know how to fix this when it occurs. What I'm hoping to do is scan a list of servers by IP and report back which server have this error. ... (6 Replies)
Discussion started by: greavette
6 Replies

2. Shell Programming and Scripting

Find command to find a word from list of files

I need to find a word '% Retail by State' in the folder /usr/sas/reports/RetailSalesTaxallocation. When I tried like below, -bash-4.1$ cd /usr/sas/reports/RetailSalesTaxallocation -bash-4.1$ find ./ -name % Retail by State find: paths must precede expression: Retail Usage: find ... (10 Replies)
Discussion started by: Ram Kumar_BE
10 Replies

3. Shell Programming and Scripting

Find the nth value in a list

Hello, I have some code that searches file names, sorts them on a field in the name, and returns the top value. # list the contents, strip off the path, and sort on field 3 as a number, returns top value TOP_OUTCOME=$(ls './'$SET_F'/'$FOLD'/'$FOLD'_anneal/'$C_PARAMS'/'$A_SET'/'*'out.txt' |... (4 Replies)
Discussion started by: LMHmedchem
4 Replies

4. Shell Programming and Scripting

How to find the X highest values in a list depending on the values of another list with bash/awk?

Hi everyone, This is an exemple of inpout.txt file (a "," delimited text file which can be open as csv file): ID, Code, Value, Store SP|01, AABBCDE, 15, 3 SP|01, AABBCDE, 14, 2 SP|01, AABBCDF, 13, 2 SP|01, AABBCDE, 16, 3 SP|02, AABBCED, 15, 2 SP|01, AABBCDF, 12, 3 SP|01, AABBCDD,... (1 Reply)
Discussion started by: jeremy589
1 Replies

5. UNIX for Dummies Questions & Answers

find from the list

Hi All, I have list such as list1: Honda, toyota, GMC list2: kia, chrysler, toyota when list1 match with list2 then echo "run this script" else echo "run the script2" (2 Replies)
Discussion started by: pavan_test
2 Replies

6. Shell Programming and Scripting

find list of files from a list and copy to a directory

I will be very grateful if someone can help me with bash shell script that does the following: I have a list of filenames: A01_155716 A05_155780 A07_155812 A09_155844 A11_155876 that are kept in different sub directories within my current directory. I want to find these files and copy... (3 Replies)
Discussion started by: manishabh
3 Replies

7. Shell Programming and Scripting

I need a script to find socials in files and output a list of those files

I am trying to find socail security numbers in files in (and under) a specific directory and output a list of the files where they are found... the format would be with no dashes just 9 numeric characters in a row. I have tried this: find /DirToLookIn -exec grep '\{9\}' /dev/null {} \; >>... (1 Reply)
Discussion started by: NewSolarisAdmin
1 Replies

8. Shell Programming and Scripting

command find returned bash: /usr/bin/find: Argument list too long

Hello, I create a file touch 1201093003 fichcomp and inside a repertory (which hava a lot of files) I want to list all files created before this file : find *.* \! -maxdepth 1 - newer fichcomp but this command returned bash: /usr/bin/find: Argument list too long but i make a filter all... (1 Reply)
Discussion started by: yacsil
1 Replies
Login or Register to Ask a Question