user971102
user971102

Reputation: 3085

zcat file not working for gzip file

I have a .gz which I need to merge and do other manipulations with (without compressing it), but I am having trouble just using zcat or gzip -dc or awk, for example when I pass these value to less -S like this:

awk '{print $1}' <(gzip -dc file.gz) | less -S

I get the incorrect column printed. When I use just less -S to view the file, only the last few columns are printed. So I thought it was a problem with the delimiter, but I have tried importing in R some lines (it is too big to import the whole file), and it seems to be space delimited since all the columns are showing up when I do this:

x=read.table("file.gz", header=T, nrows=100)

But how do I read the lines correctly to use this file with zcat?

Thank you so much for your help!

Upvotes: 0

Views: 942

Answers (1)

Anand Babu Periasamy
Anand Babu Periasamy

Reputation: 26

If you want the whole line to be printed, try $0.

awk '{print $0}' <(gzip -dc file.gz) | less -S

If you want specific columns to be printed, use -F to specific field separator. For example, if you want first field of ':' separated fields from each line (like in /etc/passwd), try this command.

awk -F':' '{print $1}' <(gzip -dc passwd.gz) |less -S

Upvotes: 1

Related Questions