[Subject Prev][Subject Next][Thread Prev][Thread Next][Subject Index][Thread Index]
RE: bash script
#include <sys/types.h>
#include <dirent.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
main()
{
DIR *pDir;
int i, length;
struct dirent *pDirent;
char name[50];
if((pDir=opendir("./")) == NULL)
{
printf("%s\n", strerror(errno));
exit(-1);
}
while((pDirent=readdir(pDir))!=NULL)
{
if(strcmp(pDirent->d_name,"a.out") !=0 &&
strcmp(pDirent->d_name,".") != 0 &&
strcmp(pDirent->d_name,"..") != 0)
{
length=strlen(pDirent->d_name);
for(i=0;i < length ; i++)
name[i]=tolower(pDirent->d_name[i]);
name[i]='\0';
rename(pDirent->d_name,name);
printf("%s\n",name);
}
}
closedir(pDir);
}
> -----Original Message-----
> From: Indraneel Majumdar [SMTP:lists@xxxxxxxxxxxx]
> Sent: Monday, February 19, 2001 8:01 PM
> To: LIP
> Subject: Re: [LIP] bash script
>
> On Mon, 19 Feb 2001, Binand Raj S. wrote:
>
> > Use this cute perl one liner to convert a word to lowercase.
> > echo $word | perl -pe 's/(.*)/\L$1/g'
>
> shouldn't that use
> tr/A-Z/a-z/g;
> instead of
> s/(.*)/L$1/g
>
> \Indraneel
>
> --
> http://www.indialine.org
>
>
> ---------------------------------------------
> An alpha version of a web based tool to manage
> your subscription with this mailing list is at
> http://lists.linux-india.org/cgi-bin/mj_wwwusr