开发者

Globbing and regular expression prob with bash script

I have a problem with my regex:

My script is written in perl.

#!/usr/bin/perl

# Inverse les colonnes 1 et 2
while(<>){
    my @cols  = split (/\|/);
    print "$cols[-3]/$cols[-4]\n";
}

exit;

I create an alias using the command :

alias inverseur="perl /laboratoire10/inverseur_colonnes.pl

I am hoping to accomplish the following:

Write a "bash" script that creates a file container for each movie title (.avi) in the file.

The original file is: http://www.genxvideo.com/genxinventory-current.xls but I have since renamed it to liste_films.csv .

All quotation marks, spaces, dashes, and other strange characters must be replaced by an underscore, "_".

The group would become the directory name and the title of the movie will follow the file name suffix( .avi). In order 开发者_如何学Pythonto do this, the code must process the fields "title" and "class" in reverse. You can reverse the fields "title" and "class" with the alias "inverter" created earlier.

The script will obviously create each directory in "/laboratoire10" before creating the .avi files. There should be 253 valid directories total. Directories are being created through a "|" with the command "xargs mkdir-pv /."

I need help augmenting my current code with a command to find .avi files whose name contains the string min/maj "wood


It is very hard to understand what exactly you are trying to do. Under the assumption you have a | separated CSV and wish to have a directory tree with CATEGORY/TITLE and the file named "cans.avi" under each directory with that name, here is a one liner perl script.

perl -mText::CSV -e '$csv = Text::CSV->new({ sep_char=>"|",binary=>1,auto_diag => 1 } ) || die; open my $fh, "<", $ARGV[0] or die; while (my $row = $csv->getline($fh)) { $file = cleaner($row->[1])."/".cleaner($row->[0]); print "mkdir $file; touch $file/cans.avi\n"; } sub cleaner($) { my($f) = @_; $f =~ s/\W/_/g; $f;}'  ~/tmp/genxinventory-current.csv 

I converted the XLS file to | separated CSV using libreoffice, so your conversion mileage (kilometerage?) may vary.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜