Sponsored Content
Top Forums Shell Programming and Scripting Print the name of files in the directory using Perl Post 302606908 by pludi on Tuesday 13th of March 2012 05:56:10 AM
Old 03-13-2012
A one-liner using only Perl (unlike the others presented so far):
Code:
perl -e 'print join "\n",grep { -f } <*>'

Explanation:
  • <*> is a glob that expands to all entries in the current directory
  • grep is a function that works pretty much like the shell utility. It expects a statement block returning true or false values on the parameters.
  • The -f is a shorthand for testing if a parameter (here it's the anonymous automatic variable $_) is a regular file or not
  • And finally it all gets nicely formatted by join and printed
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

PERL: print if files present

FOR: Windows NT 4 I want perl to read a directory. there is suposed to be two files in the folder ( file1.ini and file2.ini ) and i want perl to print "Files present" or "Files NOT present" to a text document ( report.txt ) how do i do it.? (2 Replies)
Discussion started by: perleo
2 Replies

2. Shell Programming and Scripting

print all files of a directory

At the moment I do not know anything UNIX script :rolleyes: but i need to make script that prints the content of the archives (of text) that are deposited in a directory and Later erases these archives, leaving the directory emptiness It would be like repository for print please... (9 Replies)
Discussion started by: monica
9 Replies

3. Shell Programming and Scripting

Remove files from a directory using perl

Hi all, I have the following question. Considder that in the directory /code the script remove.pl exists. What i want is to run this script and remove some files that exist in the directory /dir/tmp. I use the below code but it does not work. system("cd /dir/code"); system("rm FileName"); ... (6 Replies)
Discussion started by: chriss_58
6 Replies

4. Shell Programming and Scripting

perl with two files and print

Suppose u have two files one file >hi|23433|sp|he is RAJ<space>>hi|23333|df|He is HUMAN<space>>hi|222|gi|howru|just WOWHEISWONDERFUL >hi|25559|gs|heisANUJ<space>>hi|2232|sp|he is fool SKSIKSIKSLKSSLLS Another file HUMAN so output wil be ...if the list contain HUMAN only take it... (1 Reply)
Discussion started by: cdfd123
1 Replies

5. Shell Programming and Scripting

Print the current directory using perl

Hi I have this code to print the current directory using Perl use Cwd qw(abs_path); my $path = abs_path($0); print "$path\n"; But it is displaying my perl source code file along with the directory. like this C:\Perl\duration.pl But I want it only to display this... (1 Reply)
Discussion started by: srijith
1 Replies

6. Shell Programming and Scripting

Delete files in directory using perl

Hello All I am implementing my task in Perl and i found an issue. What i want to do is to remove files from the directory which were made 20 days back using Perl script (9 Replies)
Discussion started by: parthmittal2007
9 Replies

7. Shell Programming and Scripting

Help needed to print the not updated files in the Directory

Hi All, I have written one program to print the files which are not updated in the specified directory in .Dat file. If I am executing the same command in the command prompt its working fine but if I am executing in shell script it's not working fine. Please correct if any thing wrong in the... (3 Replies)
Discussion started by: bbc17484
3 Replies

8. Shell Programming and Scripting

Directory containing files,Print names of the files in the directory that are exactly same content.

Given a directory containing say a few thousand files, please output a list of all the names of the files in the directory that are exactly the same, i.e. have the same contents. func(a_directory_name) output -> {“matches”: , ... ]} e.g. func(“/home/my/files”) where the directory... (7 Replies)
Discussion started by: anuragpgtgerman
7 Replies

9. UNIX for Beginners Questions & Answers

Search strings from a file in files in a directory recursively; then print the string with a status

Hi All, I hope somebody would be able to help me. I would need to search a string coming from a file, example file.txt: dog cat goat horse fish For every string, I would need to know if there are any files inside a directory(recursively) that contains the string regardless of case.... (9 Replies)
Discussion started by: kokoro
9 Replies

10. UNIX for Beginners Questions & Answers

Print number of lines for files in directory, also print number of unique lines

I have a directory of files, I can show the number of lines in each file and order them from lowest to highest with: wc -l *|sort 15263 Image.txt 16401 reference.txt 40459 richtexteditor.txt How can I also print the number of unique lines in each file? 15263 1401 Image.txt 16401... (15 Replies)
Discussion started by: spacegoose
15 Replies
AUTORECONF(1)						      General Commands Manual						     AUTORECONF(1)

NAME
autoreconf2.13 - update configure scripts SYNOPSIS
autoreconf2.13 [ --help | -h ] [ --force | -f ] [ --localdir=dir | -l dir ] [ --macrodir=dir | -m dir ] [ --verbose ] [ --version ] DESCRIPTION
If you have a lot of Autoconf-generated configure scripts, the autoreconf2.13 program can save you some work. It runs autoconf2.13 (and autoheader2.13, where appropriate) repeatedly to remake the Autoconf configure scripts and configuration header templates in the directory tree rooted at the current directory. By default, it only remakes those files that are older than their configure.in or (if present) aclo- cal.m4. Since autoheader2.13 does not change the timestamp of its output file if the file wouldn't be changing, this is not necessarily the minimum amount of work. If you install a new version of Autoconf, you can make autoreconf2.13 remake all of the files by giving it the --force option. If you give autoreconf2.13 the --macrodir=DIR or --localdir=DIR options, it passes them down to autoconf2.13 and autoheader2.13 (with rela- tive paths adjusted properly). autoreconf2.13 does not support having, in the same directory tree, both directories that are parts of a larger package (sharing aclocal.m4 and acconfig.h), and directories that are independent packages (each with their own aclocal.m4 and acconfig.h). It assumes that they are all part of the same package, if you use --localdir, or that each directory is a separate package, if you don't use it. This restriction may be removed in the future. autoreconf2.13 accepts the following options: --help -h Print a summary of the command line options and exit. --force -f Remake even configure scripts and configuration headers that are newer than their input files (configure.in and, if present, aclo- cal.m4). --localdir=DIR -l DIR Look for the package file aclocal.m4 in directory DIR instead of in the current directory. --macrodir=DIR -m DIR Look for the installed macro files in directory DIR. You can also set the AC_MACRODIR environment variable to a directory; this option overrides the environment variable. --verbose Print the name of each directory where autoreconf2.13 runs autoconf2.13 (and autoheader2.13, if appropriate). --version Print the version number of Autoconf and exit. SEE ALSO
autoconf2.13(1), autoheader2.13(1), autoscan2.13(1), autoupdate2.13(1), ifnames2.13(1) AUTHORS
David MacKenzie, with help from Franc,ois Pinard, Karl Berry, Richard Pixley, Ian Lance Taylor, Roland McGrath, Noah Friedman, David D. Zuhn, and many others. This manpage written by Ben Pfaff <pfaffben@debian.org> for the Debian GNU/Linux autoconf2.13 package. Autoconf AUTORECONF(1)
All times are GMT -4. The time now is 05:14 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy