porting sed command from linux to mac

obtmind

I am trying to run a bash analysis script on my mac but the sed command is not recognising '~'. The script works perfectly on my linux workstation. My script looks like this;

#!/bin/bash
sed -n '3~9p' file.txt | awk '{print $2}' > out.dat

When I run this on my mac I get "sed: 1: "3~9p": invalid command code ~".

sat

You can try this awk instead of sed,

awk 'BEGIN {s=3;i=9} NR==s{s+=i;print}' file.txt

Even more straight forward way is,

awk 'BEGIN {s=3;i=9} NR==s{s+=i;print $2}' file.txt > out.dat

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Porting from Windows to Mac

From Dev

Porting C# mono from windows to mac

From Dev

Porting "WINAPI" datatype from Windows to Linux

From Dev

porting PCIe driver from Linux to OracleSolaris

From Dev

Standard linux sed not working in mac

From Dev

sed command is working in solaris but not in Linux

From Dev

sed on mac: 'extra characters after p command'

From Dev

zip command options on mac/linux

From Dev

Memory leakage in cudaDecodeGL sdk sample after porting from windows to linux

From Dev

Porting a PPD to Linux from OSX-filter error?

From Dev

Porting c++ from Linux to windows, '__aligned__'

From Dev

Porting Java Application from Windows to Linux - characters formatting

From Dev

sed command not working from java

From Dev

From Mac iOS to Linux

From Dev

How can we remove text from start to some particular selected word using sed command in linux

From Java

Linux CentOS sed command with regex issues

From Dev

Linux sed command replace regex string

From Dev

Linux shell su -c 'sed' command

From Dev

Linux sed command replace regex string

From Dev

SED Linux command to replace in exactly in a line

From Dev

Log the files found with the linux find and sed command

From Dev

Change the variable value using sed command in linux

From Dev

Editing a config file in linux using sed command

From Dev

Porting WinForms Application to Mac OS

From Dev

Porting WinForms Application to Mac OS

From Dev

"locate" Linux command alternative for mac OSX

From Dev

Is there a linux equivalent of the Mac OS X command "textutil"?

From Dev

How to rename files using Zsh shell and `sed` command on Mac OSX

From Dev

Cannot replace with newlines when using sed on Mac command line

Related Related

HotTag

Archive