I have a file that contains a lot of these
"/watch?v=VhsnHIUMQGM"
and I would like to output the letter code using a perl one-liner. So I try
perl -nle 'm/\"\/watch\?v=(.*?)\"/g' filename.txt
but it doesn't print anything.
What am I doing wrong?
...
Hi,
I have got an archive of many fonts but i have troubble extracting them all into one folder. i tried to write a long script for 3 hours now, it somehow breaks on a path issue. i tried piping like find . -name *.zip|unzip -d ~/fonts but it doesnt work. i changed so much in the script i wrote, that it is not really presentable :(.
eac...
Hi All,
I've used regex's in sed before and used a bit of awk, but am unsure of the exact syntax I need here...
I want to do something like:
sed -i 's/restartfreq\([\s]\)*\([0-9]\)*/restartfreq\1$((\2/2))/2/g' \
my_file.conf
where the second match is divided by 2 and then put back in the inline edit.
I've read though that sed ca...
Hi everyone,
I have a configuration file that has variables and value separate by spaces. I want to take the value (in the second column) of certain matches and inline edit the file, dividing this match by 2. I also would like to preserve spacing and use a ceiling function on the value.
For example, the file:
To recap, using an actu...
I know that usually you don't want one-liners/single commands to get too long but it seems like there's occasionally a longish one-liner that would benefit from replacing repetitive elements with a function.
Is it possible to use a short function chop down the length of your command?
For example there's no ceiling or round function ...
cat monday.csv
223.22;1256.4
227.08;1244.8
228.08;1244.7
229.13;1255.0
227.89;1243.2
224.77;1277.8
cat tuesday.csv
227.02;1266.3
227.09;1234.9
225.18;1244.7
224.13;1255.3
228.59;1263.2
224.70;1247.6
This Perl one-liner gives me the row with the highest value in the second column from the rows where in...
Trying to integrate the following Perl one-liner into a shell script. This code works within a Perl script but not as a one-liner executed from a shell script.
I've tried replacing $host with a real hostname with no luck.
#!/bin/ksh
hosts="host1 host2 host3"
PERL=/usr/bin/perl
# Check to see if hosts are accessible.
for host in $hos...
I use the following Perl syntax in my bash script:
perl -i –pe 'next if /^ *#/; s/(\b|\D)$ENV{OLD }(\b|\D)/$1$ENV{NEW }$2/' file
I want to find the OLD word without first "#" character in the file , then replaces the OLD word with NEW word
My question: I want to print "replace $OLD with $NEW" each time perl replace the $OLD ...