Find and write to a files


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Find and write to a files
# 1  
Old 08-16-2008
Find and write to a files

Hello my friends,I'm a new learner to programming in Linux so kindly can you help me to write this simple script for me and it is lists all text files "*.TXT" in a directory and writes the first line of each text-file to a file called "Aby_Name".

Thank you so much.
# 2  
Old 08-16-2008
try this......
for i in `ls *.TXT`
do
sed -n '1p' $i >> Aby_Name
done
# 3  
Old 08-16-2008
something like:
# find . -type f -name '*.txt' -exec head -n 1 {} \; >> Aby_Name
# 4  
Old 08-16-2008
if you use head it can be done in this way also
head -1 *.TXT|sed '/^==>*/d;/^$/d' >> Aby_Name
# 5  
Old 08-16-2008
Hello,

Thank you vidyadhar85 and redhead so much,

But now please redhead can you explain to me this pattern for each character Smilie.

thank you again.
# 6  
Old 08-16-2008
mmm, plz vidyadhar85 can you just expalin to this pattern for ==> and $ .Smilie
# 7  
Old 08-16-2008
when we use head with many file name like
head -1 file1 file2... it display
==>file1<==
line1

==>file2<==
line1

and so on so using sed i removed ==>file1<== and using ^$ i removed the blank lines..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Find matches and write the data before it

Hi all I am here for help once again I have two files One file is like this with one columns F2 B2 CAD KGM HTC CSP Second file is like this in 5 columns where firs column contain sometime entries of first file with space and other entries (12 Replies)
Discussion started by: Priyanka Chopra
12 Replies

2. Shell Programming and Scripting

How to find empty files in a directory and write their file names in a text?

I need to find empty files in a directory and write them into a text file. Directory will contain old files as well, i need to get the empty files for the last one hour only. (1 Reply)
Discussion started by: vel4ever
1 Replies

3. Homework & Coursework Questions

Shell script calling Perl function, sort and find data, write to new files

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: I must write a shell script that calls two external Perl functions--one of which sorts the data in a file, and... (6 Replies)
Discussion started by: kowit010
6 Replies

4. UNIX for Dummies Questions & Answers

write a program in c in unix that display the files(includ sub-direc and files within) in a sorted

the sorting is based on name of file, file size modification time stamps o f file it should dislay the output in the following format "." and ".." enteries should be ignored please give some idea how to do it (1 Reply)
Discussion started by: pappu kumar jha
1 Replies

5. Solaris

Find all "regular" files open for write on solaris?

How do I find all "regular" files on solaris(8) that are open for write ( +read as well). I tried using pfiles, and lsof commands, but not sure how to get exactly what I wanted. ps -e | awk '{ print $1 }' | xargs -i pfiles {} 2>/dev/null (10 Replies)
Discussion started by: kchinnam
10 Replies

6. UNIX for Dummies Questions & Answers

How to find out in which directories a user can write?

Hi everybody, what command can show me the directories in which a certain user can write to? Kind Regards FranzB (2 Replies)
Discussion started by: FranzB
2 Replies

7. Shell Programming and Scripting

Find all files with group read OR group write OR user write permission

I need to find all the files that have group Read or Write permission or files that have user write permission. This is what I have so far: find . -exec ls -l {} \; | awk '/-...rw..w./ {print $1 " " $3 " " $4 " " $9}' It shows me all files where group read = true, group write = true... (5 Replies)
Discussion started by: shunter63
5 Replies

8. Shell Programming and Scripting

Please help me to write a Script to find out whether website is up!!!!!!!

Hello friends I have to write a script in linux to find out the website is up or down..... Please help me in this thank you Jay (1 Reply)
Discussion started by: jai143
1 Replies

9. UNIX for Dummies Questions & Answers

find and write

Hi, I was able to succesfully search/find the files I needed using the command : find . -exec grep string {} /dev/null \; however, I would like to have the result written in a log file. Can someone please show me how to do this? Thanks in advance. Bong (3 Replies)
Discussion started by: bong m
3 Replies

10. UNIX for Dummies Questions & Answers

help me write a find command

At times I have thse Oracle logfiles that grow like crazy and fill up a specific file system. I wanted to write a find command that lists which are the biggest files from the search path..so /qbidora02/oracledba/find . -name ....... <downward to the lowest level> and list file names, sizes and... (2 Replies)
Discussion started by: jigarlakhani
2 Replies
Login or Register to Ask a Question