list files and contents


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting list files and contents
# 1  
Old 11-20-2008
Data list files and contents

I have a group of getOSinfo.out files that I would like to list the filename and then its contents out to. I can do it for each one individually, but would prefer to do it all in one shot and have one large file that has all of the oslevels and filenames. I am not very handy with scripts, so I was wondering if anyone had a script that did this already. It is on AIX so ksh is prefered, but I can probably tweak most things to work. I would like the output to look something like this:

Filename.out
content line 1
content line 2

You get the idea, I am still in my scripting infancy so please bare with me. Thanks for any help with this.

BTW this is what I was using, I know I will need a much more robust set of commands than this.

ls *.GetOSInfo.out > OSInfo.out | cat *.GetOSInfo.out >> OSInfo.out
# 2  
Old 11-20-2008
Code:
for filename in *.GetOSInfo.out 
do
        echo "Contents of file: $filename"
        cat $filename
done;

# 3  
Old 11-21-2008
Thanks

I knew it had to be very simple. Thanks for the script, I feel like a mental midget when stuff like this comes up. Like I said I am still in the crawl stage of scripting. Hopefully will be walking soon.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Unable to list folder contents

I'm unable to list the contents of a directory once I move into it. I have full permissions on this directory (called "Scripts" in the below example). The scenario is shown below in detail: Command 'ls' works fine to begin with: 1: pmn@linuxhost /home/pmn > cd /opt/smt/proiv 2:... (4 Replies)
Discussion started by: pmn
4 Replies

2. Shell Programming and Scripting

How to copy all the contents of a list of files present in a folder to a particular file?

Hi All, I want to copy all the contents of a list of files in a folder to a particular file. i am using following command: cat dir/* >> newFile.txtIt's not working. Could you please help? Thanks, Pranav (3 Replies)
Discussion started by: Pranav Bhasker
3 Replies

3. Shell Programming and Scripting

Need Help with Bash - comparing directory contents with list of files

Hey guys, need help with a script I'm trying to write. Basically I need to compare the contents of a folder called "profiles" with a list of files called "template". when the file matches the contents of the folder it needs to set a variable called "checked" to "1" Cookies to anyone... (4 Replies)
Discussion started by: Scriporium
4 Replies

4. UNIX for Dummies Questions & Answers

dtterm to list a folder contents in new window

Hi everyone,:cool: thank you in advance for any help on this I have a dtterm command to open a new small terminal window with a contents of log, and it works fine. dtterm -title "my.log" -geometry =40x30+0+550 -fn 6x13 -e tail -n 40 -f /home/logs/user.log & However what I want to do... (4 Replies)
Discussion started by: golfcents
4 Replies

5. Shell Programming and Scripting

Create a list of directory contents

Well I did a search and didn't anything for my specific case. I got a directory with a bunch of text file. All of them have the following pattern on the filename "ABCD_<As of Date>.txt" Example: ABCD_20110301.txt ABCD_20110302.txt ABCD_20110303.txt All I want to accomplish is a Korn... (3 Replies)
Discussion started by: Shark Tek
3 Replies

6. Shell Programming and Scripting

help with mailing contents to a list of people

I have to create a unix program that will mail the contents of a file to a list of users.The file to be mailed will be provided as an argument to the program on the command line. The list of users or mail recipients should be a ”variable” that is created inside the program This program MUST be... (1 Reply)
Discussion started by: toejam
1 Replies

7. Windows & DOS: Issues & Discussions

List Contents of Drive by size

I am having difficulty listing the contents of a specific disk drive including hidden files and folders by size on disk. Its been a while since i have used dos and batch files in windows as am used to UNIX so was wondering if anybody could help me with this? Regards, Alan Jackson (1 Reply)
Discussion started by: pure_jax
1 Replies

8. UNIX for Dummies Questions & Answers

Best way to list a directory's contents?

Hey guys! I'm so glad I found this site, I've had so many questions and have been left alone for roughly a year scanning man pages but It's just not quite cutting it for some things. So, I often like to list directories when browsing around my local machine, a friend's machine, or my web... (6 Replies)
Discussion started by: bbilheimer
6 Replies

9. UNIX for Dummies Questions & Answers

list contents of directory

I want to list the contents of a directory, but I do not want to use the ls, is there another way?? (3 Replies)
Discussion started by: carl_vieyra
3 Replies

10. UNIX for Dummies Questions & Answers

Message trying to list contents of directory

I'm getting this return whenever I try to do anything on a directory root# ls -al /directory ls: .: Value too large to be stored in data type. total 0 I can change directory down two levels but can not list contents of the root of this directory. ANy one seen this? (1 Reply)
Discussion started by: sallender
1 Replies
Login or Register to Ask a Question