Sponsored Content
Top Forums Shell Programming and Scripting Perl code to search for filenames that contain special characters Post 96216 by mahendramahendr on Wednesday 18th of January 2006 02:49:55 PM
Old 01-18-2006
see whether this helps..

$ ls -lrt
total 56
drwxrwx--- 3 xxxx xxxxxx 4096 Jan 6 01:05 lib
-rw-rw---- 1 xxxx xxxxxx 5 Jan 16 18:52 tmp2
-rw-rw---- 1 xxxx xxxxxx 1417 Jan 17 18:29 logfile
-rw-rw---- 1 xxxx xxxxxx 9 Jan 18 13:40 tab_del.dat
-rwxrwx--x 1 xxxx xxxxxx 105 Jan 18 17:59 tmp1.sh
-rw-rw---- 1 xxxx xxxxxx 109 Jan 18 18:11 datafile
-rw-rw---- 1 xxxx xxxxxx 129 Jan 18 18:25 datafile1
-rw-rw---- 1 xxxx xxxxxx 0 Jan 18 19:01 mah*ab
-rw-rw---- 1 xxxx xxxxxx 0 Jan 18 19:33 amh\hai
-rwxrwx--x 1 xxxx xxxxxx 148 Jan 18 19:36 tmp1.pl
-rwxrwx--- 1 xxxx xxxxxx 195 Jan 18 19:44 tmp2.pl

This is actual command :

$ find . -name "*" -print | sed 's/\\/\\\\/g' | tmp2.pl | sed 's/\\\\/\\/g'
Patter found in ./mah*ab

Patter found in ./amh\hai


here is the tmp2.pl code :

#!/usr/bin/perl -w

while( $line=<STDIN> )
{
my $vl = qx(basename $line);

if ( $vl =~ /\*|\<|\>|\?|\||:|\\|\// )
{
print "Patter found in $line\n";
}
}

the sed commands before and after tmp2.pl is needed to handle "\" character, if you are sure that it won't be there, then you can take out the sed command on both the places...

but i don't think "/" can be found in the unix file name because this is used for folders...

Last edited by mahendramahendr; 01-18-2006 at 03:55 PM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

search special characters in a file

Hello I am new to shell scripting and can anyone tell me how to check if there are any special characters in a file. Can i use grep ? thanks susie (2 Replies)
Discussion started by: cramya80
2 Replies

2. Shell Programming and Scripting

Open filename with special characters in Perl

Hi All, I am facing a weird problem. I have got a directory structure copied from windows to Linux. Some of the folders are named like /gfs/data/Dow Jones $5/ DJ FCBOT_O_tick_1998.zip /gfs/data/Dow Jones $5/ DJ FCBOT_O_tick_2000.CSV /gfs/data/Dow Jones... (6 Replies)
Discussion started by: mitrashatru
6 Replies

3. Shell Programming and Scripting

remove special characters from text using PERL

Hi, I am stuck with a problem here. Suppose i have a variable which is assigned some string containing special charatcers. for eg: $a="abcdef^bbwk#kdbcd@"; I have to remove the special characters using Perl. The text is assigned to the variable implicitly. How to do it? (1 Reply)
Discussion started by: agarwal
1 Replies

4. Shell Programming and Scripting

Want the substring of a string with special characters using perl

Hi, I am trying to separate the directory from the filename using the substring and it does not like it. $Complete_name="C:\ABCD\Reports_Split\090308.1630" I want $File_Name as 090308.1630 I tried using Substring function and it does not like slashes in the complete_name. Any... (5 Replies)
Discussion started by: sushma0907
5 Replies

5. Shell Programming and Scripting

special characters handling in perl

Hi, Here is my piece of code-- sub per_user_qna_detail { for($index=0;$index<@records;$index++) { if($records =~ m/^(.*)\s*Morocco.*Entering\s*Module::authenticate/) { printf "INSIDE per_user_qna_detail on LINE NO $index\n"; $Time_Stamp = $1;... (0 Replies)
Discussion started by: namishtiwari
0 Replies

6. Shell Programming and Scripting

Replace special characters in multiple files - perl

I have 100 files, where i want to search a set of strings and make the replacement by other strings In the first case I want to include a parameter in the name of a file LOG_DCT = $ LOG_DIR/DCT_GERAL_"$DATAINI".log replace to : LOG_DCT = $ LOG_DIR / DCT_GERAL_ $ 1_ "$ DATAINI". log I did... (1 Reply)
Discussion started by: RMSoares
1 Replies

7. Shell Programming and Scripting

awk search pattern with special characters passed from CL

I'm very new to awk and sed and I've been struggling with this for a while. I'm trying to search a file for a string with special characters and this string is a command line argument to a simple script. ./myscript "searchpattern" file #!/bin/sh awk "/$1/" $2 > dupelistfilter.txt sed... (6 Replies)
Discussion started by: cue
6 Replies

8. Shell Programming and Scripting

Perl: windows filenames escape characters

I have a perl find program that will find all files of window application stored on unix disks. Ofcourse these files contain all the weird characters windows allows, but on *nix pukes out all kinds of unwanted effects when processing these. Is their a utility that will escape all these... (3 Replies)
Discussion started by: karelb
3 Replies

9. Shell Programming and Scripting

Search avoiding special characters

Hi all, I have a list which I want to search in another file. I can do that using grep -f but the search is failing due to special characters, how do I solve this? One row in that list is amino-acid permease inda1 gb|EDU41782.1| amino-acid permease inda1 Input file to be searched... (2 Replies)
Discussion started by: gina.lizar
2 Replies

10. UNIX for Dummies Questions & Answers

Search special characters in a file and replace with meaningful text messages like Hello

Search special characters in a file and replace with meaningful text messages like Hello (2 Replies)
Discussion started by: raka_rjit
2 Replies
kpasswd(1)							   User Commands							kpasswd(1)

NAME
kpasswd - change a user's Kerberos password SYNOPSIS
/usr/bin/kpasswd [principal] DESCRIPTION
The kpasswd command is used to change a Kerberos principal's password. kpasswd prompts for the current Kerberos password, which is used to obtain a changepw ticket from the KDC for the user's Kerberos realm. If kpasswd successfully obtains the changepw ticket, the user is prompted twice for the new password, and the password is changed. If the principal is governed by a policy that specifies the length and/or number of character classes required in the new password, the new password must conform to the policy. (The five character classes are lower case, upper case, numbers, punctuation, and all other charac- ters.) OPERANDS
The following operand is supported: principal Change the password for the Kerberos principal principal. Otherwise, the principal is derived from the identity of the user invoking the kpasswd command. FILES
/tmp/ovsec_adm.xxxxxx Temporary credentials cache for the lifetime of the password changing operation. (xxxxxx is a random string.) ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWkrbu | +-----------------------------+-----------------------------+ |CSI |Enabled | +-----------------------------+-----------------------------+ SEE ALSO
SEAM(5) BUGS
If kpasswd is suspended, the changepw tickets may not be destroyed. SunOS 5.10 30 Jul 2001 kpasswd(1)
All times are GMT -4. The time now is 08:07 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy