Leila Bose
Leila Bose

Reputation: 3

Combine two commands in linux and append it to another file

awk -F "," '{print $1, $5}' < Task.txt > Task_mod.txt //this works fine

sed '/^\s*$/d' //this removes the blank lines

I am trying to put these commands together in linux and append it to Task_mod. Any ideas on how to put it together? It doesn't work with the pipe command.

Upvotes: 0

Views: 64

Answers (2)

user5773927
user5773927

Reputation:

It should work with the pipe.

awk -F "," '{print $1, $5}' < Task.txt | sed '/^\s*$/d'  > Task_mod.txt

EDIT:

  • If you want to append you need to use >> instead of >
  • What errors do you see when you run it with the pipe? I did it and I think it works...

Upvotes: 1

Rahul Verma
Rahul Verma

Reputation: 3089

You can do this in single command itself :

awk -F "," 'NF>1 {print $1, $5}' Task.txt > Task_mod.txt

Upvotes: 1

Related Questions