Displaying list of backup files using for loop


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Displaying list of backup files using for loop
# 1  
Old 10-11-2010
Displaying list of backup files using for loop

Hi,

I want to display list of last 10 backup files (with numbering) from the temporary file
c:/tmp/tmp_list_bkp.txt

Example :

Code:
1) backup_file1
2) backup_file2
3) backup_file3
........
........

I tried as below but not working.
Code:
for file in c:/tmp/tmp_list_bkp.txt
do
    echo $file
    echo ""
done

How this can be done using shell script ?

With Regards

Last edited by radoulov; 10-11-2010 at 07:14 AM.. Reason: Code tags, please!
# 2  
Old 10-11-2010
Your script did not work because the file tmp_list_bkp.txt was not been opened.
try replacing as below..

Code:
for file in $(cat c:/tmp/tmp_list_bkp.txt)

To list the only last 10 files from the file

Code:
for file in $(tail c:/tmp/tmp_list_bkp.txt)

# 3  
Old 10-11-2010
how about:

Code:
cat -n c:/tmp/tmp_list_bkp.txt

or

nl c:/tmp/tmp_list_bkp.txt

# 4  
Old 10-11-2010
Hi,

Issue solved, got the required output.

With Regards
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Ls command in a for loop displaying error

I have a few files inside a directory and in my code i am listing the files to get the filenames and do further operations.Details are given below: Dirname is taken as argument in $3 and filenames in variable $file Directory name =$3= /tmp/to-be_parsed/input Filename= $file=... (8 Replies)
Discussion started by: Jag02
8 Replies

2. UNIX for Beginners Questions & Answers

Displaying multiple variables in for loop

Hi! I've run into a problem where my variables are displayed in the wrong order. Basically I'm supposed to use a file that has information like this username:firstname:lastname:etc:etc. What I'm interested in doing is reformating it into a something more like this: username lastname,... (2 Replies)
Discussion started by: reindeermountai
2 Replies

3. Shell Programming and Scripting

Problem while displaying(cat) file content inside telnet loop .

Hi Team, Not getting the file output inside my email which i am sending from unix box. . Please refer the below code : #!/bin/sh { sleep 5 echo ehlo 10.56.185.13 sleep 3 echo mail from: oraairtel@CNDBMUREAPZP02.localdomain sleep 3 echo rcpt to: saurabhtripathi@anniksystems.com... (1 Reply)
Discussion started by: tripathi1990
1 Replies

4. Shell Programming and Scripting

While loop a file containing list of file names until the files are found?

Hi, I have a control file which will contain all filenames(300) files. Loop through all the file names in the control files and check the existence of this file in another directory(same server). I need to infinitely(2 hrs) run this while loop until all the files are found. Once a file is found,... (5 Replies)
Discussion started by: laknar
5 Replies

5. Shell Programming and Scripting

scp list of files using FOR LOOP in ksh

hi i want to scp files from remote server B to my local server A... and i have a file containing list of all files to be scped from remote server B there is a passwordless connectivity set between remote server and my local server. need a ksh script.. with a for loop that goes through... (2 Replies)
Discussion started by: billpeter3010
2 Replies

6. UNIX for Dummies Questions & Answers

Trouble displaying parameters passed into a for loop

#!/bin/bash function check_num_args() { if ; then echo "Please provide a file name" else treat_as_file $* fi } function treat_as_file() { numFiles=$# for((i=1;i<=$numFiles;i++));do echo $i ... (3 Replies)
Discussion started by: kikilahooch
3 Replies

7. Shell Programming and Scripting

Displaying Files Problem

To match all filename comprising at least three characters the first character is numeric and the last character is not alphabetic (2 Replies)
Discussion started by: polineni
2 Replies

8. Shell Programming and Scripting

Displaying a list of files

Given a set of log files like trail.<timestamp> that are generated hourly, how do I get the list of files created for the current date, using shell script? Can anyone please help me?the format of the trace file is trail.YYYYMMDDhh I also need to know how I can "grep" for a particular word in these... (2 Replies)
Discussion started by: ggayathri
2 Replies

9. AIX

How to list files in AIX 3.2 mksysb backup tape

Hi, Can anyone tell how to list files in a AIX 3.2 mksysb backup tape. Thanks! Victor Cheung (4 Replies)
Discussion started by: victorcheung
4 Replies

10. Shell Programming and Scripting

Displaying files

I am beginner to UNIX. I wanted to display 5 filesname with size from BIN directory. The order of display should be descending order in size. Can help me. (1 Reply)
Discussion started by: giridher2000
1 Replies
Login or Register to Ask a Question