Search & Replace regex Perl one liner to AWK one liner

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Search & Replace regex Perl one liner to AWK one liner
# 8  
Old 07-06-2011
Do you have any way to test that code on some Linux machine? I made some simple test with file containing one line with 4 milion random characters and it ran successfully on Linux:
[root@rhel ~]# wc -c big2
4079997 big2
[root@rhel ~]# wc -l big2
1 big2
[root@rhel ~]# grep -o ".ISA." big2
[root@rhel ~]# awk -mr 99999999 '{gsub("[^a-zA-Z0-9]ISA[^a-zA-Z0-9]","\n&")}1' big2 > big3
[root@rhel ~]# wc -l big3
2 big3

As you can see big2 got cut into two lines as a result of that one-liner. I would really recommend trying Linux for that task.
# 9  
Old 07-06-2011
Ok will do ... which flavor of Linux do you recommend ... Ubuntu? Fedora? something else?

---------- Post updated at 03:39 PM ---------- Previous update was at 03:37 PM ----------

PS: I don't have access to a unix box ... I'll have to install/run linux in windows
# 10  
Old 07-07-2011
Any relatively updated distribution will do. For the ease of installation and later usage I would recommend Ubuntu installed in VirtualBox Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

PERL one liner

hi, I am using PERL one liner for oracle database connection as : $PERL -e "use DBI; DBI->connect(qw(DBI:Oracle:SID user passwd));" is there a way to append select statement to this connection ? i.e. DB connection and select stmt in one line ? how to do sysdba connection using one lines... (1 Reply)
Discussion started by: talashil
1 Replies

2. UNIX for Dummies Questions & Answers

What awk 1-liner will replace value in 1stField of a delimited file with the value of '5' ?

Hi, I am a newbie to awk. Here is my problem. Looking for an awk 1-liner to solve it: My Computing Environment: - Solaris10 - I prefer to use csh or sh shells 1. Lets say my input file is File1.dat (delimter = | ) and looks as follows: (File1.dat) ... (1 Reply)
Discussion started by: andy b
1 Replies

3. UNIX for Dummies Questions & Answers

Perl one liner to replace text

Not quite a unix question but problem in a perl command. Taking a chance if someone knows about the error cat 1 a b c d perl -p -e 's/a/b/g' 1 b b c d What is the problem here?? perl -p -i -e 's/a/b/g' 1 Can't remove 1: Text file busy, skipping file. (2 Replies)
Discussion started by: analyst
2 Replies

4. Shell Programming and Scripting

replace awk with a perl one liner (REGEXP and FS)

hello, I want to replace awk with a perl one liner in unix. i use in awk REGEX and FS ( field separator) because awk syntaxes in different unix os versions have not the same behaviour. Awk, Nawk and GNU Awk Cheat Sheet - good coders code, great reuse i have a file named "file" and want... (5 Replies)
Discussion started by: bora99
5 Replies

5. UNIX for Dummies Questions & Answers

One liner pattern search with awk/sed/grep

I have an array containing bunch of characters. I have to check this array for specific character and if "Not Found than" use a goto statement to go to USAGE set options = (A B C D E F) @ i = 0 while ($i <= ${#options}) if ($options != "F" || $options != "D") then goto USAGE endif @... (1 Reply)
Discussion started by: dixits
1 Replies

6. Shell Programming and Scripting

Replacing Awk with One-liner Perl

can someone help me translate the following command, from: /usr/bin/awk "/^$TOFDAYM $TOFDAYD /,0" $LOGFILE to something like perl -e ..... basically, i want to use perl to do awk functions within a shell script. i want to do the above awk, using perl. any suggestions? (9 Replies)
Discussion started by: SkySmart
9 Replies

7. Shell Programming and Scripting

Need an awk / sed / or perl one-liner to remove last 4 characters with non-unique pattern.

Hi, I'm writing a ksh script and trying to use an awk / sed / or perl one-liner to remove the last 4 characters of a line in a file if it begins with a period. Here is the contents of the file... the column in which I want to remove the last 4 characters is the last column. ($6 in awk). I've... (10 Replies)
Discussion started by: right_coaster
10 Replies

8. Shell Programming and Scripting

awk: Multiple search patterns & print in an one liner

I would like to print result of multiple search pattern invoked from an one liner. The code looks like this but won't work gawk -F '{{if ($0 ~ /pattern1/) pat1=$1 && if ($0 ~ /pattern2/) pat2=$2} ; print pat1, pat2}' Can anybody help getting the right code? (10 Replies)
Discussion started by: sdf
10 Replies

9. Shell Programming and Scripting

awk multiple-line search and replace one-liner

Hi I am trying to search and replace a multi line pattern in a php file using awk. The pattern starts with <div id="navbar"> and ends with </div> and spans over an unknown number of lines. I need the command to be a one liner. I use the "record separator" like this : awk -v... (8 Replies)
Discussion started by: louisJ
8 Replies

10. Shell Programming and Scripting

awk/perl one-liner assist

In a ~4GB file there are lines like, - Jan/23/2011:00:00:00 +0000 "URL Google HTTP/1.1" 45 56 208 - "" ".Net; Fox" - -... (3 Replies)
Discussion started by: gameboy87
3 Replies
Login or Register to Ask a Question