3

Suppose I have a file like this:

COLUMN
1
2
3
4

If I wanna run and process it with GNU parallel but skipping first line aka header, I tried this:

parallel -a test.txt -k --pipepart --will-cite --skip-first-line cat

However, --skip-first-line is not working as I expect:

parallel -a test.txt -k --pipepart --will-cite --skip-first-line cat
COLUMN
1
2
3
4

I expected this:

1
2
3
4

Is it possible to skip the first line using pipepart in parallel?

2 Answers 2

2

The bug is fixed in Git.

https://git.savannah.gnu.org/cgit/parallel.git/snapshot/parallel-master.tar.gz

parallel -a test.txt -k --pipepart --skip-first-line cat
0

I found a solution using the replacement string {#} aka sequence number. The first header will always be in sequence 1, hence we can treat this specially when we parse it. For example with a script:

#!/bin/bash

_test()
{
    if [[ "$1" == 1 ]]; then
        :
    else
        cat
    fi
}

export -f _test

parallel -a demo.txt -k --pipepart --will-cite _test {#}

Running this script yields the expected results:

1
2
3
4

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .