Cut the first column in listed files > PERL script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Cut the first column in listed files > PERL script
# 1  
Old 07-01-2010
Question Cut the first column in listed files > PERL script

Hi All,

Using this command wc -l *e* > create2.txt i'm getting the following output >>>create2.txt listed output files, my requirement is how to cut the first coloum in all the files mentioned in create2.txt in perl.

Code:
 50 allignment.pl
       3 create.txt
       4 application.txt
       8 exeout.txt
      32 test.txt
      11 test2.txt
       8 test3.txt


Last edited by adaleru; 07-01-2010 at 06:36 AM..
# 2  
Old 07-01-2010
Hi, Try this

Code:
system(" cut -d' ' -f1 create2.txt ");

# 3  
Old 07-01-2010
Try

Code:
$ awk '{ print $1 }' create2.txt

# 4  
Old 07-01-2010
Not working guys. can any one suggest me the PERL script
# 5  
Old 07-01-2010
Code:
$ perl -anle 'print $F[0]' create2.txt

# 6  
Old 07-01-2010
Quote:
Originally Posted by agn
Code:
$ perl -anle 'print $F[0]' create2.txt

Hi ,

Thanks for your reply, however its giving error
# 7  
Old 07-01-2010
Which error? How should the output look like?

Code:
50
3
4
8
32
11
8

or
Code:
 50 
       3 
       4 
       8 
      32 
      11 
       8

or even
Code:
allignment.pl
create.txt
application.txt
exeout.txt
test.txt
test2.txt
test3.txt

Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need awk or Shell script to compare Column-1 of two different CSV files and print if column-1 matche

Example: I have files in below format file 1: zxc,133,joe@example.com cst,222,xyz@example1.com File 2 Contains: hxd hcd jws zxc cst File 1 has 50000 lines and file 2 has around 30000 lines : Expected Output has to be : hxd hcd jws (5 Replies)
Discussion started by: TestPractice
5 Replies

2. Shell Programming and Scripting

Delete files listed in text file

Hi Team, Here's the scenario, I have a text file called "file_list.txt". Its content is as follows. 111.tmp 112.tmp 113.tmp 114.tmp These files will present in "workdir" directory. It has many files. But only the files present in file_list.txt has to be deleted from the workdir... (7 Replies)
Discussion started by: kmanivan82
7 Replies

3. Shell Programming and Scripting

Total number of files in the folder should be listed

Hi All, When i give the ls -lrt to list out all files with total number of files , i get the output as ls -lrt total 72 -rw-r--r-- 1 hari staff 796 Jul 11 09:17 va.txt -rw-r--r-- 1 hari staff 169 Jul 13 00:20 a.log -rwxr-xr-x 1 hari staff 659 Aug... (9 Replies)
Discussion started by: Kalaihari
9 Replies

4. Shell Programming and Scripting

perl Compare zone files in directory with what is listed in named.conf

I would really appreciate any assistance that I can get here. I am fairly new to perl. I am trying to rewrite my shell scripts to perl. Currently I have a shell script (using sed, awk, grep, etc) that gets a list of all of the zone files in a directory and then looks in named.conf for what... (0 Replies)
Discussion started by: brianjb
0 Replies

5. Shell Programming and Scripting

Capture listed files from find command

Hi all, I am using command find $InputPath -type f -mtime +30 However, I need to capture the file listed in screen. May I know how to achieve this? Thank you. (12 Replies)
Discussion started by: ashly
12 Replies

6. Shell Programming and Scripting

Compare Two Files(Column By Column) In Perl or shell

Hi, I am writing a comparator script, which comapre two txt files(column by column) below are the precondition of this comparator 1)columns of file are not seperated Ex. file1.txt 8888812341181892 1243548895685687 8945896789897789 1111111111111111 file2.txt 9578956789567897... (2 Replies)
Discussion started by: kumar96877
2 Replies

7. Shell Programming and Scripting

Files copying - [ Listed files alone. ] - Shell script

Hi All, I am doing this for svn patch making. I got the list of files to make the patch. I have the list in a file with path of all the files. To Do From Directory : /myproject/MainDir To Directory : /myproject/data List of files need to copy is in the file: /myproject/filesList.txt ... (4 Replies)
Discussion started by: linuxadmin
4 Replies

8. Shell Programming and Scripting

Cut the first column in listed files

1.give the command wc -l *e* > create2.txt 2.now create2.txt contains a.txt b.txt c.txt d.txt 3.create2.txt is a random file ( output may vary depends on time) (eg: a1.txt , b1.txt,c1.txt,d1.txt if time changes) 4. now i want to cut the first colum from all the files mentioned in... (12 Replies)
Discussion started by: adaleru
12 Replies

9. Shell Programming and Scripting

Moving files listed in a data file to a new directory using Perl

Hi, I have a data file that lists a number of files. I want to move the files named in that one to another directory. Here's what I have: #!/usr/bin/perl -w open(FILE, "<collision.txt"); my @lines=<FILE>; foreach my $lines (@lines) { system("mv $lines collisions/."); } close(FILE); ... (2 Replies)
Discussion started by: renthead720
2 Replies

10. HP-UX

CVSWeb - Directories listed but files not listed

I am using CVSWeb on HPUnix. When i access it, all directories are listed but files are not listed. I am getting the error "NOTE: There are 51 files, but none matches the current tag. " in tomcat sevrer log i am getting the message "rlog warning: Missing revision or branch number after -r"... (0 Replies)
Discussion started by: ganesh
0 Replies
Login or Register to Ask a Question