Sajha.com Archives
Unix Shell help

   guys anyone knows how to do following in 26-Nov-02 santosh neupane
     It may work. check out 1 ls ./Windows | 26-Nov-02 dawn
       Santosh Ji, Timro ta din banyo:) Sabai 26-Nov-02 Rusty
         1)grep -il Set *.sql |wc -l 2)grep -i 26-Nov-02 Shiva Shiva!!
           Sorry, .sql ko thau ma 'Window' hunuparn 26-Nov-02 Shiva Shiva!!


Username Post
santosh neupane Posted on 26-Nov-02 08:47 AM

guys anyone knows how to do following in Unix Shell?

Write a pipe/Shell script that will accomplish the following:

1.Count all the files in current directory that contain the word 'Windows'.
2.Count the number of times 'Windows' occurs in all the files in the current directory.
3.Delete all //... comments from a C++ program.
4.For each file in the current directory, change its name so that any upper-case letters are changed to lower case. For example 'uGLy.doC' will be changed to 'ugly.doc' Hint: generate a file that contains all the required mv operations, then execute that file
dawn Posted on 26-Nov-02 11:21 AM

It may work. check out
1 ls ./Windows |wc -l
2.grep Windows * | wc -l
3.sed 's|//.*$||g' test1.C > test2.C
4.this is one hacked version from the net
#!/bin/sh
doren() {
newname=`echo "$1" |sed '
h
s/.*\///
y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/
x
s/[^/]*$//
G
s/\n//
'`
[ "$1" != "$newname" ] &&
{
echo "$1"
echo " --> $newname"
mv "$1" "$newname"
}
}
if [ $# -eq 1 ]
then
find "$1" -depth |
{
while read a
do
doren "$a"
done
}
else
echo "$0: usage: $0 directory"
echo "translates all file and directory names"
echo "in the specified hierachy to lower case"
fi
Rusty Posted on 26-Nov-02 11:33 AM

Santosh Ji,
Timro ta din banyo:) Sabai Answer payo. By the way, do you go to college in RI?
Shiva Shiva!! Posted on 26-Nov-02 11:43 AM

1)grep -il Set *.sql |wc -l

2)grep -i Set *.sql |wc -l

3)sed ' s/\/\///' c++program_filename > temp_filename
mv temp_filename c++program_filename

4)
typeset -l new_name
typeset old_name

ls * | while read rec
do
echo $rec
old_name=$rec
new_name=$rec
if [[ $old_name != t.ksh ]]; then
mv $old_name $new_name
fi
done

Let me know if doesn't work!!
Shiva Shiva!! Posted on 26-Nov-02 11:45 AM

Sorry, .sql ko thau ma 'Window' hunuparne.

Maile .sql ma test gareko le!!

hehe