Tag Info

Hot answers tagged

3

Getopt::Std replaced getopt.pl -- you may find it in CPAN Perl4::CoreLibs try: cpan> install Perl4::CoreLibs


3

Your script can be slightly modified to only process the states you need: netstat -ant | awk '/ESTABLISHED|LISTEN|CLOSE_WAIT/ {print $6}' | \ sort | uniq -c | sort -n A further step would be to everything with awk, e.g. : netstat -ant | awk ' /ESTABLISHED|LISTEN|CLOSE_WAIT/ {count[$6]++} END { for(s in count) { printf("%12s : %6d\n", s, ...


3

Two possibilities I can think of: The usual one is that you are running the bash script from something like cron, where your user profile script hasn't run and set up $PATH. In this case you can specify system "/path/to/fastacmd ... within the perl script so that it doesn't depend on the path, or you can set the $ENV{PATH}= ...


3

The utility that's actually designed for this is csplit NAME csplit - split a file into sections determined by context lines SYNOPSIS csplit [OPTION]... FILE PATTERN... So in this case csplit file /Fub_Level_DACGE\(%\)/ will produce files xx00 and xx01 containing the two parts.


2

By default, perl read one line input at a time, so your regex never matches. For working with multiple lines input, you have two options. Enable paragraph mode: perl -i.bak -00pe ... or slurp the whole file: perl -i.bak -0777pe ... (Any value above -0400 will cause perl to slurp the whole file, -0777 is used for convention)


1

Assuming your file names don't contain newline characters and your grep supports the -o option: find [[:upper:]] -type f | grep -Eo '^./[0-9]{3}' | sort | uniq -c


1

This will read file file0 and write its lines to file1 until the line starting Fub_Level_DACGE is reached. Starting with that line, all lines are written to file2: awk -v f=file1 '/^Fub_Level_DACGE/{f="file2"} {print>f}' file0 How it works -v f=file1 Set the variable f to the name of the initial output file, file1. /^Fub_Level_DACGE/{f="file2"} ...


1

awk '# Process "0pairs_file". Build a "pair" array (keys only). # Include leading an trailing space to unambiguously search of each field value via index(). NR==FNR{ pair[NR]=" "$1" "$2" "; next } # Determine number of records in "pairs_file"0. FNR==1{ pz=NR-1 } # "pz" size of "pair" array # Process "main_file" # ...


1

perl to the rescue: $ perl -p00e 's/\n,/,/g' file playerID,yearID,gameNum,gameID,teamID,lgID,GP,startingPos gomezle01,1933,0,ALS193307060,NYA,AL,1,1 ferreri01,1933,0,ALS193307060,BOS,AL,1,2 gehrilo01,1933,0,ALS193307060,NYA,AL,1,3 gehrich01,1933,0,ALS193307060,DET,AL,1,4 dykesji01,1933,0,ALS193307060,CHA,AL,1,5 cronijo01,1933,0,ALS193307060,WS1,AL,1,6 ...



Only top voted, non community-wiki answers of a minimum length are eligible