Skip to main content
trivial filename change
Source Link
Mike B
  • 9.2k
  • 25
  • 75
  • 98

CentOS 5.9

I've got a server with a foo.ext.gz file located in a variety of random directories.

Example:

  • /opt/fooapp/foosubdirectory/foo_foo_randomnumber/blah/blah/foo.ext.gz
  • /opt/fooapp/foosubdirectory/foo_foo_differentrandomnumber/blah/blah/foo.ext.gz
  • /opt/fooapp/foosubdirectory/foo_foo_anotherdifferentrandomnumber/blah/blah/foo.ext.gz

I'd like to run a bash command that will:

  1. Locate foo.ext.gz files
  2. Extract the contents of the gz file in the same directory that its respective GZ file resides in
  3. Keep the original gz file intact.

If I was doing this manually, I'd start with find / -iname footfoo.ext.gz. After that, I'd copy the directory the file resides in and type something like:

gunzip -c /opt/fooapp/foosubdirectory/foo_12345/blah/blah/foo.ext.gz > /opt/fooapp/foosubdirectory/foo_12345/blah/blah/foo.ext 

The problem here is that I need to manually do this process for several dozen files/directories.

Is there a way I can leverage xargs or a for loop?

CentOS 5.9

I've got a server with a foo.ext.gz file located in a variety of random directories.

Example:

  • /opt/fooapp/foosubdirectory/foo_/blah/blah/foo.ext.gz
  • /opt/fooapp/foosubdirectory/foo_/blah/blah/foo.ext.gz
  • /opt/fooapp/foosubdirectory/foo_/blah/blah/foo.ext.gz

I'd like to run a bash command that will:

  1. Locate foo.ext.gz files
  2. Extract the contents of the gz file in the same directory that its respective GZ file resides in
  3. Keep the original gz file intact.

If I was doing this manually, I'd start with find / -iname foot.ext.gz. After that, I'd copy the directory the file resides in and type something like:

gunzip -c /opt/fooapp/foosubdirectory/foo_12345/blah/blah/foo.ext.gz > /opt/fooapp/foosubdirectory/foo_12345/blah/blah/foo.ext 

The problem here is that I need to manually do this process for several dozen files/directories.

Is there a way I can leverage xargs or a for loop?

CentOS 5.9

I've got a server with a foo.ext.gz file located in a variety of random directories.

Example:

  • /opt/fooapp/foosubdirectory/foo_randomnumber/blah/blah/foo.ext.gz
  • /opt/fooapp/foosubdirectory/foo_differentrandomnumber/blah/blah/foo.ext.gz
  • /opt/fooapp/foosubdirectory/foo_anotherdifferentrandomnumber/blah/blah/foo.ext.gz

I'd like to run a bash command that will:

  1. Locate foo.ext.gz files
  2. Extract the contents of the gz file in the same directory that its respective GZ file resides in
  3. Keep the original gz file intact.

If I was doing this manually, I'd start with find / -iname foo.ext.gz. After that, I'd copy the directory the file resides in and type something like:

gunzip -c /opt/fooapp/foosubdirectory/foo_12345/blah/blah/foo.ext.gz > /opt/fooapp/foosubdirectory/foo_12345/blah/blah/foo.ext 

The problem here is that I need to manually do this process for several dozen files/directories.

Is there a way I can leverage xargs or a for loop?

deleted 26 characters in body
Source Link
Anthon
  • 81.4k
  • 42
  • 174
  • 228

CentOS 5.9

Hi All,

I've got a server with a foo.ext.gz file located in a variety of random directories.

Example:

  • /opt/fooapp/foosubdirectory/foo_/blah/blah/foo.ext.gz
  • /opt/fooapp/foosubdirectory/foo_/blah/blah/foo.ext.gz
  • /opt/fooapp/foosubdirectory/foo_/blah/blah/foo.ext.gz

I'd like to run a bash command that will:

  1. Locate foo.ext.gz files
  2. Extract the contents of the gz file in the same directory that its respective GZ file resides in
  3. Keep the original gz file intact.

If I was doing this manually, I'd start with find / -iname foot.ext.gz. After that, I'd copy the directory the file resides in and type something like:

gunzip -c /opt/fooapp/foosubdirectory/foo_12345/blah/blah/foo.ext.gz > /opt/fooapp/foosubdirectory/foo_12345/blah/blah/foo.ext 

The problem here is that I need to manually do this process for several dozen files/directories.

Is there a way I can leverage xargs or a for loop?

Any thoughts?

CentOS 5.9

Hi All,

I've got a server with a foo.ext.gz file located in a variety of random directories.

Example:

  • /opt/fooapp/foosubdirectory/foo_/blah/blah/foo.ext.gz
  • /opt/fooapp/foosubdirectory/foo_/blah/blah/foo.ext.gz
  • /opt/fooapp/foosubdirectory/foo_/blah/blah/foo.ext.gz

I'd like to run a bash command that will:

  1. Locate foo.ext.gz files
  2. Extract the contents of the gz file in the same directory that its respective GZ file resides in
  3. Keep the original gz file intact.

If I was doing this manually, I'd start with find / -iname foot.ext.gz. After that, I'd copy the directory the file resides in and type something like:

gunzip -c /opt/fooapp/foosubdirectory/foo_12345/blah/blah/foo.ext.gz > /opt/fooapp/foosubdirectory/foo_12345/blah/blah/foo.ext 

The problem here is that I need to manually do this process for several dozen files/directories.

Is there a way I can leverage xargs or a for loop?

Any thoughts?

CentOS 5.9

I've got a server with a foo.ext.gz file located in a variety of random directories.

Example:

  • /opt/fooapp/foosubdirectory/foo_/blah/blah/foo.ext.gz
  • /opt/fooapp/foosubdirectory/foo_/blah/blah/foo.ext.gz
  • /opt/fooapp/foosubdirectory/foo_/blah/blah/foo.ext.gz

I'd like to run a bash command that will:

  1. Locate foo.ext.gz files
  2. Extract the contents of the gz file in the same directory that its respective GZ file resides in
  3. Keep the original gz file intact.

If I was doing this manually, I'd start with find / -iname foot.ext.gz. After that, I'd copy the directory the file resides in and type something like:

gunzip -c /opt/fooapp/foosubdirectory/foo_12345/blah/blah/foo.ext.gz > /opt/fooapp/foosubdirectory/foo_12345/blah/blah/foo.ext 

The problem here is that I need to manually do this process for several dozen files/directories.

Is there a way I can leverage xargs or a for loop?

Rollback to Revision 2
Source Link
Anthon
  • 81.4k
  • 42
  • 174
  • 228

CentOS 5.9

Hi All,

I've got a server with a foo.ext.gz file located in a variety of random directories.

Example:

/opt/fooapp/foosubdirectory/foo_<randomnumber>/blah/blah/foo.ext.gz /opt/fooapp/foosubdirectory/foo_<differentrandomnumber>/blah/blah/foo.ext.gz /opt/fooapp/foosubdirectory/foo_<anotherdifferentrandomnumber>/blah/blah/foo.ext.gz 
  • /opt/fooapp/foosubdirectory/foo_/blah/blah/foo.ext.gz
  • /opt/fooapp/foosubdirectory/foo_/blah/blah/foo.ext.gz
  • /opt/fooapp/foosubdirectory/foo_/blah/blah/foo.ext.gz

I'd like to run a bash command that will:

  1. Locate foo.ext.gz files
  2. Extract the contents of the gz file in the same directory that its respective GZ file resides in
  3. Keep the original gz file intact.

If I was doing this manually, I'd start with find / -iname foot.ext.gz. After that, I'd copy the directory the file resides in and type something like:

gunzip -c /opt/fooapp/foosubdirectory/foo_12345/blah/blah/foo.ext.gz > /opt/fooapp/foosubdirectory/foo_12345/blah/blah/foo.ext 

The problem here is that I need to manually do this process for several dozen files/directories.

Is there a way I can leverage xargs or a for loop?

Any thoughts?

CentOS 5.9

I've got a server with a foo.ext.gz file located in a variety of random directories.

Example:

/opt/fooapp/foosubdirectory/foo_<randomnumber>/blah/blah/foo.ext.gz /opt/fooapp/foosubdirectory/foo_<differentrandomnumber>/blah/blah/foo.ext.gz /opt/fooapp/foosubdirectory/foo_<anotherdifferentrandomnumber>/blah/blah/foo.ext.gz 

I'd like to run a bash command that will:

  1. Locate foo.ext.gz files
  2. Extract the contents of the gz file in the same directory that its respective GZ file resides in
  3. Keep the original gz file intact.

If I was doing this manually, I'd start with find / -iname foot.ext.gz. After that, I'd copy the directory the file resides in and type something like:

gunzip -c /opt/fooapp/foosubdirectory/foo_12345/blah/blah/foo.ext.gz > /opt/fooapp/foosubdirectory/foo_12345/blah/blah/foo.ext 

The problem here is that I need to manually do this process for several dozen files/directories.

Is there a way I can leverage xargs or a for loop?

CentOS 5.9

Hi All,

I've got a server with a foo.ext.gz file located in a variety of random directories.

Example:

  • /opt/fooapp/foosubdirectory/foo_/blah/blah/foo.ext.gz
  • /opt/fooapp/foosubdirectory/foo_/blah/blah/foo.ext.gz
  • /opt/fooapp/foosubdirectory/foo_/blah/blah/foo.ext.gz

I'd like to run a bash command that will:

  1. Locate foo.ext.gz files
  2. Extract the contents of the gz file in the same directory that its respective GZ file resides in
  3. Keep the original gz file intact.

If I was doing this manually, I'd start with find / -iname foot.ext.gz. After that, I'd copy the directory the file resides in and type something like:

gunzip -c /opt/fooapp/foosubdirectory/foo_12345/blah/blah/foo.ext.gz > /opt/fooapp/foosubdirectory/foo_12345/blah/blah/foo.ext 

The problem here is that I need to manually do this process for several dozen files/directories.

Is there a way I can leverage xargs or a for loop?

Any thoughts?

salutation removed
Source Link
Anthon
  • 81.4k
  • 42
  • 174
  • 228
Loading
added 11 characters in body
Source Link
Mike B
  • 9.2k
  • 25
  • 75
  • 98
Loading
Source Link
Mike B
  • 9.2k
  • 25
  • 75
  • 98
Loading