Skip to main content
Commonmark migration
Source Link

as per man tar (a long reading)

--transform=EXPRESSION, --xform=EXPRESSION
Use sed replace EXPRESSION to transform file names.

I used

find . -name \*.py -print | xargs tar cf tmp7/test-py.tar --transform=s:./.*/:: -

all files were on same level.

#sed expression

sed expression

  • s:./.*/:: : (greedy) replace ./.*/ by nothing.

#bonus:

bonus:

find . -name \*.py -print | sed -e s:./.*/:: | awk 'a[$1]++ { print ; }'

will print dupplicate filename.

as per man tar (a long reading)

--transform=EXPRESSION, --xform=EXPRESSION
Use sed replace EXPRESSION to transform file names.

I used

find . -name \*.py -print | xargs tar cf tmp7/test-py.tar --transform=s:./.*/:: -

all files were on same level.

#sed expression

  • s:./.*/:: : (greedy) replace ./.*/ by nothing.

#bonus:

find . -name \*.py -print | sed -e s:./.*/:: | awk 'a[$1]++ { print ; }'

will print dupplicate filename.

as per man tar (a long reading)

--transform=EXPRESSION, --xform=EXPRESSION
Use sed replace EXPRESSION to transform file names.

I used

find . -name \*.py -print | xargs tar cf tmp7/test-py.tar --transform=s:./.*/:: -

all files were on same level.

sed expression

  • s:./.*/:: : (greedy) replace ./.*/ by nothing.

bonus:

find . -name \*.py -print | sed -e s:./.*/:: | awk 'a[$1]++ { print ; }'

will print dupplicate filename.

added 132 characters in body
Source Link
Archemar
  • 32.3k
  • 18
  • 75
  • 107

as per man tar (a long reading)

--transform=EXPRESSION, --xform=EXPRESSION
Use sed replace EXPRESSION to transform file names.

I used

find . -name \*.py -print | xargs tar cf tmp7/test-py.tar --transform=s:./.*/:: -

all files were on same level.

sed#sed expression : s:./.*/::

  • s:./.*/:: : (greedy) replace ./.*/ by nothing.

#bonus: (greedy) replace ./.*/ by nothing

find . -name \*.py -print | sed -e s:./.*/:: | awk 'a[$1]++ { print ; }'

will print dupplicate filename.

as per man tar (a long reading)

--transform=EXPRESSION, --xform=EXPRESSION
Use sed replace EXPRESSION to transform file names.

I used

find . -name \*.py -print | xargs tar cf tmp7/test-py.tar --transform=s:./.*/:: -

all files were on same level.

sed expression : s:./.*/:: : (greedy) replace ./.*/ by nothing.

as per man tar (a long reading)

--transform=EXPRESSION, --xform=EXPRESSION
Use sed replace EXPRESSION to transform file names.

I used

find . -name \*.py -print | xargs tar cf tmp7/test-py.tar --transform=s:./.*/:: -

all files were on same level.

#sed expression

  • s:./.*/:: : (greedy) replace ./.*/ by nothing.

#bonus:

find . -name \*.py -print | sed -e s:./.*/:: | awk 'a[$1]++ { print ; }'

will print dupplicate filename.

Source Link
Archemar
  • 32.3k
  • 18
  • 75
  • 107

as per man tar (a long reading)

--transform=EXPRESSION, --xform=EXPRESSION
Use sed replace EXPRESSION to transform file names.

I used

find . -name \*.py -print | xargs tar cf tmp7/test-py.tar --transform=s:./.*/:: -

all files were on same level.

sed expression : s:./.*/:: : (greedy) replace ./.*/ by nothing.