Perl is a high-level, general-purpose, interpreted, dynamic programming language. It was originally developed by Larry Wall as a general-purpose Unix scripting language to make report processing easier, over a period with support from open source community, it has evolved and matured to be used for ...
-3
votes
1answer
49 views
perl script explanation please [closed]
Write a perl program that reads in a text file containing
one word per line. Create a hash containing the words read as
keys and the number of times they have been read as the value.
Print ...
2
votes
3answers
86 views
Easy way to parse syslog date format
I'd like to write a script that analyses the last week's syslog.
But my syslog logs in a stupid date format, e.g. "May 22". If it logged as 2013-05-22, this task would be trivial.
Is there a way ...
3
votes
3answers
75 views
sed + how to remove character/s that start or ended on each number
How do I remove the . character(s) that start in the beginning of each number or end on each number?
Remark – perl one liner also good alternative for sed.
Example input:
.23.12.44.5.
.233.3.3.3
...
1
vote
1answer
42 views
Perl dependency issue
I've installed CentOS 6.3 (i386) recently.
It has two perl binary
/usr/bin/perl (v5.10.1)
/usr/local/appx/perl/bin/perl (v5.8.8)
My question: Is it possible to install some other funtinonality ...
5
votes
2answers
194 views
Special character '#' in Perl SSH command
I try to send command using SSH in my perl script with # but it gets truncated right at #
Example:
Input text is :
$message = "Product ID # STK000134"
The SSH command is :
$execute=`ssh -q ...
5
votes
5answers
204 views
How to remove multiple blank lines from a file?
I have some text-files I use to take notes in - just plain text, usually just using cat >> file. Occasionally I use a blank line or two (just return - the new-line character) to specify a new ...
1
vote
2answers
37 views
Trimming one part if equal to another part?
I use an e-mail quote attribution string like this:
On dd mmm yyyy hh:mm +hhmm, from info@example.org (Example Dot Org):
where info@example.org is the sender's e-mail address and Example Dot Org is ...
0
votes
2answers
87 views
Reordering strings in linux
How can I change lines around using the command line?
e.g. I have these lines:
Acct-Status-Type = Start
User-Name = "37XXXXXXX"
Event-Timestamp = "Apr 12 2013 15:56:55 AMT"
I need to ...
4
votes
3answers
144 views
Delete XML node containing certain element
I want to remove all Placemarks from a KML file that contain the element <tessellate>. The following block should be wholly removed:
<Placemark>
...
-1
votes
3answers
65 views
Sorting IP address according to the second field in file
in my ksh script I need to add the following task ( OS - linux/solaris )
I have the following file
more test.txt
/etc/backup/app 172.1.120 172.110.120
/etc/backup/app 172.1.120.12 ...
0
votes
1answer
56 views
read line by line and take a string in line and assign that string to the subsequent line using perl
Data file is fixed length file, and I want to read file line by line and take a string from the current line, and then append that string to the subsequent line and write into another file.
For ...
-4
votes
1answer
49 views
How to transform two delimited ASCII files
These are 2 common delimited, text file transformation problems I'd like to find scripts to do (I dont know if awk or perl is best for these tasks).
csh is the default shell on my Solaris10 unix ...
0
votes
3answers
49 views
Grep end regex matching
On OS X, system_profiler SPHardwareDataType outputs:
Hardware Overview:
Model Name: MacBook Pro
Total Number of Cores: 4
L2 Cache (per Core): 256 KB
L3 Cache: 8 MB
Memory: 8 GB
I want to ...
1
vote
3answers
171 views
awk, sed, grep, perl… which to print out in this case?
I have this syntax in a file (http response times from analog):
<thead><tr><th class="x">seconds</th><th class="R">reqs</th><th ...
10
votes
3answers
393 views
What does ${1+“$@”} mean in a shell script, and how does it differ from “$@”?
In the Perl documentation, perlrun(1) suggests launching Perl scripts using a bilingual shell/Perl header:
#!/bin/sh
#! -*-perl-*-
eval 'exec perl -x -wS $0 ${1+"$@"}'
if 0;
What does ${1+"$@"} ...
0
votes
2answers
68 views
perl one liner + print VALUE in the end of the line
The following perl one liner checks if $CURRENT_VERSION matches $NEW_VERSION exactly, and prints it if it does.
Example:
CURRENT_VERSION=223.3.12.4.5.3
NEW_VERSION=223.3.12.4.5.3
DATE=17.3.2013
...
2
votes
1answer
84 views
perl + combine exec command with perl one liner line
I have the following short perl script rename.pl. How can I translate this script to one liner perl syntax? And how to combine the perl one liner in find command?
rename.pl
#!/usr/bin/perl
$op = ...
0
votes
1answer
197 views
Rename files and directories with a special characters on solaris machines
The target of the following code ( commands ) is to rename files/directories and also support files/directories with a special characters as "@" or "." etc
those commands are run fine on Linux ...
0
votes
2answers
66 views
Running something in a cron environment?
Cron executes whatever program is sent to it in such a fashion that anything written to STDERR causes either the kernel (or cron I'm unsure) to receive SIGPIPE. How does this functionality work? Is ...
1
vote
2answers
77 views
renaming a directory and its subdirs without affecting their files
I have to rename directories under the root directory with prefix "ms_PF" and then rename their subdirectories with the modified name of the main directory with an extra "_", and then copy all ...
0
votes
0answers
42 views
Spreadsheet::XLSX returning < > and & instead of < > &
I'm using
...
use Spreadsheet::XLSX;
use Spreadsheet::XLSX::Fmt2007;
use Spreadsheet::XLSX::Utility2007;
...
to parse an xlsx spreadsheet where a cell contains the value
() appear in ...
0
votes
0answers
48 views
How do I reinstall the bioperl modules on Ubuntu?
I am trying to learn bioinformatics the hard way. I have no background in Linux, Ubuntu, bash, Perl, Python, etc. I'm trying to use several programs, mostly the bioperl modules, that have been ...
3
votes
1answer
131 views
Send log messages to a different location
I want to send messages from C program and from Perl script to a file (for example, /var/log/my_log). I don't have access to the syslog daemon configuration, so I think in launch a differente syslog ...
1
vote
1answer
60 views
Perl CPAN module download fails
The download for the 'App-xml_grep2-0.14.tar.gz' perl module continually fails for me.
cpan http://search.cpan.org/CPAN/authors/id/M/MI/MIROD/App-xml_grep2-0.14.tar.gz
Please login with USER and ...
0
votes
1answer
231 views
Failed dependencies trying to install package 'libxml2'
I am trying to install libxml2, but my system complains about dependencies. The dependent packages exist on system.
The ultimate goal is to install xml_grep2, I have been trying various methods ...
2
votes
1answer
61 views
How to list all present optical drivers?
How can I list all the installed optical drivers with udev or any other core-based tool (perl is also very good) ?
P.S.: I know about the wodim --devices command, but it's an undesirable ...
0
votes
2answers
645 views
How to use the find command in Perl script?
Could someone tell me why the find command always go to the root directory but not the directory that is specified in $srceDir?
my $srceDir = "/mnt/SDrive/SV/Capture Data/";
my $find_cmd = 'find ...
0
votes
1answer
63 views
Error trying to call find from perl
use warnings;
use File::Find;
my $srceDir = "//mnt/Share_Drive/Verizon PM&T/Capture Files/";
opendir(DIR, $srceDir) or die "Can't open $srceDir: $!";
my @files = (find -type f -newermt "12 Feb ...
2
votes
5answers
489 views
How can I split a text file into multiple text files using Perl?
I have a file ABC_TabDelim.txt that contains the following:
00:00:00:00 00:00:05:00 01SC_001.jpg
00:00:14:29 00:00:19:29 01SC_002.jpg
00:01:07:20 00:01:12:20 01SC_003.jpg
00:00:00:00 00:00:03:25 ...
1
vote
1answer
190 views
Identify text/ascii files in Linux/Solaris
I have a little project to build bash script that search in the OS ( Linux/Solaris ) the current IP address from files and replace them with other IP address.
The problem is that IP address could be ...
1
vote
3answers
266 views
linux/solaris + verify duplicate valid IP address from file
what the best way to find duplicate IP from file ( I have ksh script in this script I need to write function that check for duplicate IP )
for example if IP - 192.1926.23.52 exists twice in file - ...
5
votes
2answers
90 views
Getting or cloning the users current terminal?
I have to work with a script that forks and launches an instance of xterm in order to display log output in one window and have an interactive interface in the other. Personally I prefer rxvt-unicode ...
1
vote
5answers
208 views
Replacing lines in files with file contents
I have several files which contain some PHP includes and I want to substitute them with the file contents. The file looks like
foo
<?php
include("file1.php");
?>
bar
baz
<?php
...
2
votes
2answers
70 views
'tie' [nonexisting] files to programs
Recently, I just had an idea which turned out to be pretty useful under certain circumstances. But first some simple explanation:
In Perl, you have the option to tie variables to some functions ...
1
vote
2answers
78 views
No perldoc for POSIX?
On some other systems, like Ubuntu, perldoc POSIX works, but on Arch,
%> perldoc POSIX
No documentation found for "POSIX".
%> perldoc /usr/lib/perl5/core_perl/POSIX.pm
No documentation found ...
0
votes
1answer
225 views
Whats the most efficient way of adding milliseconds to this code?
#-----------------------------------------------------------------------------
#
# Get time string
#
#-----------------------------------------------------------------------------
#
sub formatTime
...
0
votes
1answer
393 views
Linux + replace STRING/WORD in file according to rule
My target is to replace any word/string/Any characters in file
with new word/string according to the following rules:
If numeric characters on the left side of word/string then we not replace the ...
3
votes
1answer
171 views
Use all system memory in Solaris
I am doing server testing and intentionally trying to crash a virtual Solaris server by using all memory. Server has a ulimit of 15 GB (several hundred GB of total system/swap memory). Is there a ...
0
votes
1answer
228 views
linux + perl + replace any WORD in file with special characters with condition
Example1 work fine when I want to replace OLD_TEXT with NEW_TEXT ( its replace also all special characters as $@^%)(_+`:; etc ..)
example1
export OLD_TEXT='$$OLD_WORD$$'
export ...
0
votes
1answer
57 views
Issue with installing CPAN XML::RSS
I'am running debian on my server and want to install the CPAN module XML::RSS.
But I get this error:
http://pastebin.com/5syPaQfe (Pastebin because it's really long)
I'am trying to install ...
2
votes
1answer
465 views
Email picture attachments as inline along with the email body
I'm right now working with a script for emailing attachment (.png pics). Since I'm using mutt command with -a option, the email is sent as a mail attachment.
I want these .png pictures to be mailed ...
2
votes
4answers
325 views
Replace all but a set of characters in a file with newline
how to delete all characters in file except numbers and "." ,
each word (numbers/dot) should be in new line in file see example2
the solution can be with sed or awk or ksh syntax
remark - ...
0
votes
3answers
64 views
Fixing header and print
I have header starting with '>' and I want fix the header by keeping first word and removing other shown as in output.txt and print it
input.txt
>AGAJ01065549.1 ...
0
votes
3answers
223 views
Split and print
I have tab-demlimted text file with 50,000lines. I want to split the first column and print as shown in output.txt
Input.txt
rt|371443144|mb|MN556661.1| 2200443 A
rt|371443344|mb|MN556645.1| ...
5
votes
2answers
320 views
Replacing missing value blank space with zero
I have input.txt tab-delimited text file around 30K lines, I would like to check each row (s1..s30K lines) for missing value (i.e blank space) and fill the missing value with zero value.See out.txt
...
1
vote
2answers
448 views
Fetch values from plist file on Linux
I have bash script which was written for OS X and now ported to Linux. I don't have access to the Linux box. The bash script would read values from plist files using the defaults read and PlistBuddy ...
0
votes
1answer
385 views
/bin/sh: ./check-dependencies.pl: not found — but check-dependencies.pl exists!
I'm trying to build Moses, but when I run make I get the following output:
minakshi@minakshi-Vostro-3500:~/Desktop/working-dir/moses/scripts$ make release
# Compile the parts
make all
make[1]: ...
3
votes
3answers
2k views
invalid SSL_version specified at /usr/share/perl5/IO/Socket/SSL.pm line 332
Since I upgraded my PC from (k)ubuntu 12.04 to 12.10 I receive this error message when trying to send an email using sendemail.
Installing an older version of IO::Socket::SSL is not an option. I ...
1
vote
1answer
157 views
Combining files with 4 columns each, into 4 files for each column [closed]
So I have a bunch of text files which look like this:
T1
r1 a b c d
r2 d e f g
...
T2
r1 h i j k
r2 l m n o
...
And I want to make FOUR different text files in the following ...
1
vote
5answers
152 views
frequency of occurence
I have a tab-delimited text file, that is around 3K lines long.
I want to calculate frequency of data appearing in it, in 10,000 ranges.
Input.txt
Price
500
1500
10001
15000
17000
...