or
for file in *; do
case $(< $file) in
*"$file"*) printf '%s\n' "$file";;
esac
done
# (none tested)
--
Stphane
> for file in *; do
> fgrep -l -- "$file" "$file"
> done
> or
> for file in *; do
> case $(< $file) in
> *"$file"*) printf '%s\n' "$file";;
> esac
> done
> # (none tested)
> --
> Stphane
Now I shall wait and see if they have any integrity
or were just trying to pull some kind of sick power
trip.
I have those e-mails right in front of me.
Bruce<+>
i hope you can use grep. then this should work:Quote:> Hi.
> I dont know what , to do. I must made script which will found in current
> directory files ,
> which have in their body their name. I dont know what too do. I must do this
> without
> sed, ed and awk etc. . Maybe at the begining small sugestion? Regards. Paul.
> P.S. Sorry for my english
for i in *; do
grep "$i" "$i" 2>/dev/null 1>&2 && echo "$i"
done
but if you don't have even grep, still don't lose your hope :)
for i in *; do
while read f; do
[ "${f#*$i*}" == "" -a ! -z "$f" ] && echo "$i"
done < "$i"
done
greetings...
ps. if you'll have any problems, try my email (in polish)
--
http://tri10o.republika.pl http://www.bsod.org
[snip]
>> # (none tested)
>> --
>> Stphane
>A number of people here have jumped all over my
>case for posting untested scripts, going so far
>as to send me abusive e-mails.
Stphane stated that neither of the scripts he posted has been tested.
And both of them work.
Not the same situation. Not at all.Quote:>Now I shall wait and see if they have any integrity
>or were just trying to pull some kind of sick power
>trip.
No kidding?Quote:>I have those e-mails right in front of me.
Regards,Quote:>Bruce<+>
.. Ted Kennedy's car has killed more people than my gun.
> for file in *; do
> fgrep -l -- "$file" "$file"
> done
[ -d "$file" ] || fgrep -l -- "$file" "$file"
or:
[ -f "$file" ] && fgrep -l -- "$file" "$file"
Though if you're using GNU grep, the -s option will suffice.
When there is an insignificant difference between portable andQuote:> or
> for file in *; do
> case $(< $file) in
[ -f "$file" ] && case `cat "$file"` in
--Quote:> *"$file"*) printf '%s\n' "$file";;
> esac
> done
> # (none tested)
(tested, works better than mine)Quote:>> for file in *; do
>> fgrep -l -- "$file" "$file"
>> done
>> or
>> for file in *; do
>> case $(< $file) in
>> *"$file"*) printf '%s\n' "$file";;
>> esac
>> done
you see, some people here don't have to test their script'sQuote:> A number of people here have jumped all over my
> case for posting untested scripts, going so far
> as to send me abusive e-mails.
> Now I shall wait and see if they have any integrity
> or were just trying to pull some kind of sick power
> trip.
make a website with them ;)Quote:> I have those e-mails right in front of me.
--
http://tri10o.republika.pl http://www.bsod.org
You're right. However, strictly speaking, the OP didn't mentionQuote:>> for file in *; do
>> fgrep -l -- "$file" "$file"
>> done
> I'd test for, and skip, directories:
> [ -d "$file" ] || fgrep -l -- "$file" "$file"
$ mkdir dir
$ touch dir/dir
$ fgrep -l dir dir
dir
because dir contains "dir", i.e. a file (or directory
or whatever) whose name contains "dir". A directory can also be
considered as a file.
But, it's a good point. Non-regular files (fifos, devices,
sockets, doors, symlinks, directories...) should probably be
skipped as they could cause the script to hang or return
unexpected results.
[...]
Also note those options:Quote:> Though if you're using GNU grep, the -s option will suffice.
--
Stphane
[...]Quote:> In article <9WVs9.6578
So you have copies of the e-mails I am referringQuote:> >A number of people here have jumped all over my
> >case for posting untested scripts, going so far
> >as to send me abusive e-mails.
> Well, not exactly. You've been flamed, and rightly so, for posting
untested
> scripts that are not identified as untested, and do not work.
Please post them for everyone to see.
Bruce<+>
>> In article <9WVs9.6578
>[...]
>> >A number of people here have jumped all over my
>> >case for posting untested scripts, going so far
>> >as to send me abusive e-mails.
>> Well, not exactly. You've been flamed, and rightly so, for posting
>untested
>> scripts that are not identified as untested, and do not work.
>So you have copies of the e-mails I am referring
>to?
>Please post them for everyone to see.
Regards,
Doug Miller
--
Real email address is alphageek /at/ milmac /dot/ com
.. Ted Kennedy's car has killed more people than my gun.
> >> In article <9WVs9.6578
> >[...]
> >> >A number of people here have jumped all over my
> >> >case for posting untested scripts, going so far
> >> >as to send me abusive e-mails.
> >> Well, not exactly. You've been flamed, and rightly so, for posting
> >untested
> >> scripts that are not identified as untested, and do not work.
> >So you have copies of the e-mails I am referring
> >to?
> >Please post them for everyone to see.
> No, Bruce, I'm talking about the newsgroup postings. DUH!
May I suggest a change of medication?
Or, alternatively, you could just get a life.
Bruce<+>
Quote:> Regards,
> Doug Miller
> --
> Real email address is alphageek /at/ milmac /dot/ com
> .. Ted Kennedy's car has killed more people than my gun.
>> >> In article <9WVs9.6578
>> >[...]
>> >> >A number of people here have jumped all over my
>> >> >case for posting untested scripts, going so far
>> >> >as to send me abusive e-mails.
>> >> Well, not exactly. You've been flamed, and rightly so, for posting
>> >untested
>> >> scripts that are not identified as untested, and do not work.
>> >So you have copies of the e-mails I am referring
>> >to?
>> >Please post them for everyone to see.
>> No, Bruce, I'm talking about the newsgroup postings. DUH!
>No, actually. What you are expressing is a
>number of neuroses that I am incapable of helping
>you with.
>May I suggest a change of medication?
>Or, alternatively, you could just get a life.
Regards,
Doug Miller
--
Real email address is alphageek /at/ milmac /dot/ com
.. Ted Kennedy's car has killed more people than my gun.
1. Copy files using filenames from text files with shell script or bash script
How can I do this????
I have the file "lista.txt", and this file have the next information:
one.txt
two.txt
five.txt
six.txt
-------------------
This files exist in the same directory that "list.txt", I would like to
copy this files to other directory
Using Windows the batch file would be like this: for /f "tokens=*" %i
in (list.txt) do copy "%i" destdir\
How can I do something like that in REDHAT??
Best Regards
3. Looking for shell script to DOS batch file converter
5. How to attach file to EMAIL MESSAGE within shell script(Korn shell)
6. How to copy files from a device to a PC using serial communication.
7. NEWBIE-Shell scripting - When to use script variable vs. create tmp file???
8. OpenBSD 2.6 Remote reboot problem
9. handling SIGINT in shell scripts when executing another shell script.
10. Q: How can I have a shell script call another shell script...
11. Shell script invoking other shell scripts
12. Convert Bash shell script to Korn shell script
13. Shell Script Help (C-Shell Script)