Help with listing given files in a given directory path


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help with listing given files in a given directory path
# 1  
Old 08-03-2010
Power Help with listing given files in a given directory path

hello every one,
i'm a novice in the field of Linux, so please help me out with this problem.
a text file with the following syntax is given:

[/home/abcd/a/3]
file1
file2
file3
[/home/abcd/a/33]
file4
file5

a script is to be written to list all d file names and tar the files with the filename bckup-<date>-<time>.tar.
given files can be anywhere in d directory path, the code should search for the files, display them n then tar with the given name convention.
i've done it partially, please helpSmilie
# 2  
Old 08-03-2010
Can you put your requirement clearly ? that will help you to get a solution faster.
# 3  
Old 08-04-2010
Bug

Input file syntax:
[directory path]
file1
file2
file3

[directory path2]
file4
file5

Script should read the above given file, prepare the list of files mentioned in it using the directory paths, and create a tar containing all the given files. The tar filename should have the following naming convention: bkup-<date>-<time>.tar

i've tried it in this way..the input file is assign3.txt, my script file has the following-

Code:
echo "list of files are:"
grep  "[[]*[]]" assign3.txt > 3.txt 
grep -o "/[a-zA-Z0-9]*]"  3.txt | tr ']' '/' | cut -d "/" -f 2 
echo $1
echo $2
a1=$1
b1=$2
tar -cvf bkup-`date +"<%m-%h-%y>"`-`date +"<%k-%M>"`.tar $a1 $b2

the last directory names in the given paths are stored in $1 and $2..
i've to use those directory names to tar..
i'm storing them in variables a1 and b1 and using them in tar.. but its not helping..

Last edited by pludi; 08-04-2010 at 02:49 AM.. Reason: code tags, please...
# 4  
Old 08-04-2010
How does you assign3.txt file look like ? What are the contents ? Can you put a sample file here ? Also $1 and $2 will be empty what are you passing to the script ?

Thanks,
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Homework & Coursework Questions

Listing the files in a directory

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: A script that takes any number of directories as command line arguments and then lists the contents of each of... (3 Replies)
Discussion started by: Phaneendra G
3 Replies

2. UNIX for Dummies Questions & Answers

Listing files in a Unix Directory ending with .....

Hi Unix Gurus, I need to list all files in a Unix Directory which either end with a .pdf or .rtf and they should be case insensitive ie .Pdf , .pDF , .RtF etc are also possible. How can i accomplish this with with a ls command ? If not then a find command. (6 Replies)
Discussion started by: pchegoor
6 Replies

3. Shell Programming and Scripting

listing the files without cd to the path

Hi all, I want to check the list of all directories and links in a particular directory and here, i have the list of the directories/links which i need to print on screen. I used the below command to check the dir/links, cd path1 ; ls -ltd `cat dir_links_list` But here, i don't want to... (3 Replies)
Discussion started by: raghu.iv85
3 Replies

4. Shell Programming and Scripting

Listing files in a given directory with given extention

for some reason my code does not give the right number of files. can omeone help me please? (2 Replies)
Discussion started by: andrew1400
2 Replies

5. Shell Programming and Scripting

Just listing size, timestamp & name of files in a directory

How can I list the files in a directory and just show the file size, date stamp, timestamp and file name.. I've been trying to ls -lrt the directory to a file and then use the cut command but I'm not having any luck with getting the proper results.. I thought i could use the -f switch and count... (4 Replies)
Discussion started by: Jazmania
4 Replies

6. UNIX for Dummies Questions & Answers

Listing files in a non-parent directory

Hi, Edit: The title should really read listing files in a non-parent directory, sorry! Im trying to get one of my Bash scripting assignments done for uni and now I'm stuck. This is probably going to be one of those kick yourself moments but, in my script I have a variable usrDir which... (2 Replies)
Discussion started by: Adzi
2 Replies

7. UNIX for Dummies Questions & Answers

Listing files with full path

Hi, I need to store all the files in a directory to a text file with its full path. The example below can explain: ./File1.txt ./File2.txt ./Folder1/File11.txt ./Folder1/File12.txt ./Folder1/Folder11/File111.txt ./Folder2/file21.txt : : The ls -R1 command won't give the result as... (5 Replies)
Discussion started by: r_sethu
5 Replies

8. UNIX for Dummies Questions & Answers

listing files in a directory in bases of size

Hi , I want to list all files in the order of size . Just want to know which files occupies more size and which occupies less size . Is it possible with ls command ? :) Thanks, Arun. (1 Reply)
Discussion started by: arunkumar_mca
1 Replies

9. UNIX for Dummies Questions & Answers

Recursive directory listing without listing files

Does any one know how to get a recursive directory listing in long format (showing owner, group, permission etc) without listing the files contained in the directories. The following command also shows the files but I only want to see the directories. ls -lrtR * (4 Replies)
Discussion started by: psingh
4 Replies

10. UNIX for Dummies Questions & Answers

listing files and directory in Page wise

!hello , Any one can me how can i display files and directory in Pagewise. how to change prompt in UNIX . (1 Reply)
Discussion started by: smdakram
1 Replies
Login or Register to Ask a Question