Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

All Questions

Tagged with
0
votes
2answers
18 views

Returning wrong results in perl script [duplicate]

I am running this command on linux shell it works smoothly sed -i 's/\[-.*-]//g' error .txt What it does is it removes patterns like [-any text-] along with the brackets and - sign. but when I try ...
0
votes
3answers
71 views

perl regex - How to match foobar that does not begin with (\s*//\s*)

Basically I want to find foobar on uncommented lines like: // foobar # do not match me foobar # match me otherfoobar # do not match me To match the commented lines I use this: ^(\s*//...
0
votes
1answer
35 views

Getting Error with system() in perl

' Number found where operator expected at ./scripttemp.perl line 5, near ""sed -i -r "4" (Missing operator before 4?) String found where operator expected at ./scripttemp.perl line 5, near "}" ...
-2
votes
0answers
30 views

Using Grep in perl script [on hold]

I want to execute the grep command inside my perl script. this is my command : grep -nr "{+" error.txt > error1.txt I want to find this character in file error.txt and want to print the line ...
1
vote
3answers
546 views

Delete a part of a line with sed?

I have the next output: Date Time: June 22 12:40:00 Product User Host IP Software User User *.***.***.*** Software1 User User *.***.***.*** I tried some functions with sed and awk, but is not ...
5
votes
2answers
450 views

Could someone explain this shebang line which uses sh and then does exec perl?

This is from Programming Perl, Fourth Edition. It's about executing a Perl script. Finally, if you are unfortunate enough to be on an ancient Unix system that doesn’t support the magic #! line, ...
0
votes
0answers
113 views

Safely granting permission to a Perl script to change users and groups of filed downloaded with rsync

I've got a Perl script which is a wrapper to a Net::OpenSSH object which I use to rsync a remote server's files to my local machine. I'm using the archive, -a, option to preserve file ownership and ...
-2
votes
2answers
165 views

I have four files with 10 lines of each, how to get output like below

I have 4 files. I need to check that all the files have equal number of lines. If the numbers of lines differ, I need to detect this and output, for example: #file1 - 10 lines, file2 - 9 lines, ...
1
vote
1answer
82 views

Help with oneliner - create random files, rename to two-char filename, fill with random strings [closed]

Would anyone be so kind and point me on how to make an one-liner from this? Or maybe use sed/awk/xargs? Or Perl? Or just make it simpler I have achieved this by searching stackexchange and editing ...
0
votes
1answer
1k views

Perl script to check if possible to ssh to remote server

I have a perl script in which i want to first check if it possible to ssh into the server before i actually do ssh. So if it possible to ssh, then go ahead and ssh into that server, otherwise handle ...
-2
votes
1answer
355 views

How to write a Perl Script to find a string in a file?

I want to write a Perl script to find the variable if present in the TEST titles only, not in the FIRST, SECOND or THIRD titles. So there are N number of variables in a files before the TEST titles; ...
4
votes
4answers
2k views

Have a script with perl shebang, need to switch to bash in the middle

I have a script with two blocks: The first block is written in perl, the second block is written in bash How do I switch shells (perl --> bash) in the middle of the script? Script attached below: ...
2
votes
2answers
73 views

Script load two arguments

I have perl script which need two arguments, for example: ./PerlScript 0001 192.168.100.200 But I need run this script more time (40x). ./PerlScript 0003 192.168.100.202 ./PerlScript 0061 192.168....
0
votes
1answer
690 views

Base64 decode and overwrite file

I have a file which contains base64 encoded image data: ~/dog/1.jpg I put it there via SSH, and base 64 encoded the data so it would be safe to transfer in the terminal. Assume the base64 image data ...
0
votes
2answers
26 views

Missing information handling text with Perl

Hi everyone I have been working with this script: perl -F',\s+' -lane ' @ARGV and $h{$F[1]}=$F[0],next; /^Device ID:\s+(\S+)/ && $h{$a=$1} .. /^$/ || eof() and do{ /^$/ || ...
25
votes
1answer
3k views

At sign after shebang?

In the Apache httpd project's "support/apxs.in" script, a text surrounded with @ signs comes after #!. That is, the first line of the script is: #!@perlbin@ -w Is this a Perl thing or a UNIX kernel ...
-2
votes
1answer
36 views

Perl script which operates on an input file

I am trying to write a script which takes a file as input, reads each line of that file, performs a find based on the value of the file contents, and writes the output to a different file. What I have ...
1
vote
1answer
114 views

Unix Solaris script for executing commands in multiple remote hosts

I have two hosts for eg. 1) 00.00.00.01 having regions on diffrent ports for eg. a) a1region (port 0011) b) b1region (port 0012) c) c1region (port 0013) 2) 00.00.00.02 having regions on diffrent ...
1
vote
3answers
453 views

Find pattern and remove it from all files [closed]

Please help me solving following problem. Remove all pairs of characters \ n from Test_Macro in all files. Please see below example: Fil1.txt Test_Macro(abc, def, "\n string1 string2 \n test string",...
2
votes
3answers
2k views

Log file grep entries from last 30 min

I am creating a script that will email errors/warnings from a log. I would like to have this sent every half hour but I only want to send it if there is a new entry. How would I grep out only the last ...
0
votes
1answer
3k views

How to run a perl script inside another perl script

I have two Perl scripts and want to use one script from another. The scripts are called script1.pl and script2.pl. I want to run the below command inside script1.pl : /home/user/script2.pl /var/log/...
3
votes
3answers
138 views

rename(1)-like script in Perl, but for copying files?

So there's this rename(1) Perl thing. It suits my task precisely, except that I need it to basically cp files instead of mv. How to achieve that? I have quite a few rules of renaming, all expressed ...
-2
votes
2answers
53 views

Data Manipulation

I have a data as mentioned below. host_name Server1.domain.com contacts DL - Desktop contact_groups ravi, raj, rahim host_name Server2.domain.com contact_groups DL-Server host_name Server3....
1
vote
3answers
60 views

How to add the aggregated numbers in a file

I need to write a script which will add the values for the same string in different lines. For example when a file contains the following: abc,10 xyz,20, abc,30, ghd,40 xyz,10 script should check ...
0
votes
2answers
3k views

Script for ssh automatic login to a specific port

So currently, the "traditional" way to connect through SSH is the following one: ssh USERNAME@HOST -p PORT I would like to create a script in which I will include all the appropriate information (...
0
votes
2answers
74 views

Parsing a Blocked file and generating smaller files

I have a file like below: 1weather dnsndjsdn 2nm bdbdb bdbdbdbdnnd 3gfdu hsihdishdis 5 1hdohdsohsoihssodhoishs 2nfdksnkdsnfsdsjndkdj 3kjdscdskndskjndndsdsdsd 5 Like wise I might have close to 20,...
1
vote
3answers
714 views

Bash - Perl Script variable insertion

I'm having some troubles trying to insert a bash variable inside my perl code. The purpose of the code is to execute a certain perl printing command into a terminal using a bash script file. I have ...
4
votes
5answers
738 views

Count unique associated values in awk (or perl)

I've already found "How to print incremental count of occurrences of unique values in column 1", which is similar to my question, but the answer isn't sufficient for my purposes. First let me just ...
0
votes
2answers
72 views

Taking numbers from a text file and add them together

I have text file with hundreds of lines like below. I am trying to find a way to pull the number of records and add them together. Then I want to put the answer in a separate file This is my first ...
1
vote
2answers
103 views

Execute Perl commands from a specific IP?

I have a Debian Jessie 8 server with three unique IPv4 IPs. I connect to the server from Windows 7 via Putty. I can open three Putty windows using each of the three IPs. I am trying to execute a Perl ...
0
votes
1answer
325 views

Perl one-liner to replace a code block

I have a file foo.txt hello world first line to change second line to change I would like to write a perl one-liner that changes foo.txt to read hello world this is my ...
1
vote
2answers
3k views

Script that only counts Established, TIME_WAIT, and Closed Wait connections using Netstat

I'm trying to make a script (using Perl, but it isn't necessary) that will only count the number of Established, Time_Wait, and Closed_Wait connections on a system and print them in terminal. So far I'...
1
vote
1answer
107 views

file name as argument and sort in descending way in perl?

I have this perl script #!/usr/bin/perl use strict; open my $df, '<', 'file.txt' or die "open: $!\n"; my %h; while (<$df>) { $h{$_}++ for split /\s+/; END{ for (keys %h){ ...
2
votes
1answer
69 views

Neutralisation of data from Windows to Unix

I just noticed that other platforms files (Windows) had to cause me many bugs, like here, in my regexes. Mostly, the line ending ^M. There seems to be many ways to do dos2unix, like here described. ...
0
votes
2answers
294 views

How to update three CSV files based on a fourth file

I have four csv files, and I want to update a set of three, based on the values in the fourth file. file_1 contains names. file_2 their numerical ids. file_3 contains ids from file_1 and file_2, ...
2
votes
1answer
86 views

How to write this replacement with condition

I want to replace now within my working directories the word -> with $\to$ if the word is not within verbatim environment. Pseudocode Replace all entriens of -> with $\to$ everywhere else but not ...
4
votes
2answers
1k views

How to write this pseudocode where condition

This question is extension of this question about listing questions of directories. I get a problem that I need to understand the original section of the text. Current output where you see the ...
0
votes
1answer
924 views

Uuencode displaying attachment content in email body

I am using uuencode with mailx to attach a zip file. In following code, the if block works perfectly and I get Deletions.zip as an attachment in the email. But, whenever the else block is executed I ...
4
votes
1answer
4k views

Convert xml subtitle file to srt format

I have a xml subtitle that looks like this: <?xml version="1.0" encoding="utf-8" ?><transcript> <Item from="1.16" duration="4.68"><![CDATA[(Dong-hyuk is coming to see you now.) ...
2
votes
0answers
444 views

How to print the first three lines and last two lines of a file using perl? [closed]

Through the command line I draw one or several of the patterns found text.xml file: perl -ln0e 'while(/<PMResult.*?<\/PMResult>/gs) { $x=$&;print $x if $x=~/BCCEL-[1-3]/}' text.xml I ...
1
vote
1answer
5k views

Using EXIFTool to add EXIF data from filenames

There is a set of photos with timestamps in their filenames like these: Photo on 3-09-12 at 9.24 PM #2.jpg Photo on 3-09-12 at 9.24 PM #1.jpg Photo on 3-09-12 at 8.23 PM.jpg etc. ("3-09-12", ...
0
votes
0answers
68 views

replacement script multiple targets

I have this input file Name=code_229633_138;isoforms=1 Name=code_229633_138 Name=code_229633_138;Target=R77_09738T0 Name=code_230519_1;isoforms=1 Name=...
2
votes
3answers
241 views

grab multiple lines after a matching target line

This question is similar to How to show lines after each grep match until other specific match? thus answers may be similar to those there. I am trying to grab and extract from a file the lines that ...
0
votes
2answers
2k views

Convert perl script to bash

The following script it's about monitoring some logs, the $timestamp is at log at every line that something happens. Example: 03:19:13.4 Begin summary update for ads.doc.inventory....
1
vote
1answer
1k views

Cannot locate libncurses.so location when running a file

I'm trying to run a file name remote build which is to build a package on a target server. My target server is HP-UX-itanium 64 bit. When I run the remote build, somehow it cannot find libncurses.so ...
12
votes
6answers
11k 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 subject/...
4
votes
5answers
8k 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 ...
2
votes
1answer
4k 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 ...
5
votes
2answers
9k 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
2k 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]: ...