Extracting a subfolder from (GNU)tar archive - wildcard

What is the right spell to extract a subfolder from a tar archive when you do not know the base name?
I have a tar archive with the following structure:
myarchive.tar
|
+-- StrangeName_Including_variable_parts
|
+-- bin
| |
| +-- Uninteresting_stuff
|
+-- src
|
+-- Stuff
|
+-- I_need
My problem is to extract "src" and put it somewhere on my disk regardless of the name of base directory (StrangeName_Including_variable_parts).
I tried something like:
tar xf myarchive.tar -C destination src
But it doesn't seem to do what I need.
What I would need is:
destination
|
+-- src
|
+-- Stuff
|
+-- I_need

Extract with wildcard:
tar -xf myarchive.tar -C destination --wildcards '*/src'
See: man tar

Related

Count directory and exclude dir

I have the fallowing command to count all image in folder "find . -type f | sed -e 's/.*.//' | sort | uniq -c | sort -n | grep -Ei '(tif| jpg| jpep| gif)$'" What do I need to add to it to have exclude a directory?

Symfony My debug toolbar doesn't appear on my website anymore

While debugging, I actually lost my debug toolbar (like, it doesn't appear anymore on my website) so I tried various thing to have it back:
composer require symfony/profiler-pack
composer require symfony/apache-pack
And even:
composer remove apache-pack
composer require symfony/apache-pack
But I still can't have it back. I found nothing that can help on the Internet.
Thanks !
Edit:
The command bin/console debug:router _wdt return this:
| Route Name | _wdt |
| Path | /_wdt/{token} |
| Path Regex | #^/_wdt/(?P<token>[^/]++)$#sD |
| Host | ANY |
| Host Regex | |
| Scheme | ANY |
| Method | ANY |
| Requirements | NO CUSTOM |
| Class | Symfony\Component\Routing\Route |
| Defaults | _controller: web_profiler.controller.profiler::toolbarAction |
| Options | compiler_class: Symfony\Component\Routing\RouteCompiler
In .env.local AND .env.dev be sure APP_ENV=dev and APP_DEBUG=1
Also, in config/packages/dev/web_profiler.yaml you have something like
web_profiler:
toolbar: true
Also, if you change any values in these you should clear your cache php bin/console cache:clear

How to tar multiple files without getting their paths

I was at a code interview which I failed, but I'm trying to understand it anyways.
From root, I was supposed to first get all html files and tar them on a single command.
After I failed, I was able to do it on my own like this:
find . -name "*.js" | xargs tar -cvf tar.tar
My problem is, it mimics the whole tree structure of the system. I wanted a solution that would put all the files on the same level, if I were to run on a folder with
-
| a.js
| b.html
| c.js
|_ folder
| g.html
My resulting tar ends up having a folder called folder with g.html in it. When ran from root, this looks terrible
root#i5-cpu:~/work_area/php# tree d1
d1
├── d2
│   ├── f2_1.js
│   └── f2_2.js
├── f1_1.js
└── f1_2.js
1 directory, 4 files
root#i5-cpu:~/work_area/php# find . -name "\*.js" | xargs tar -cvf tar.tar --transform='s,.*/,,'
./d1/d2/f2_1.js
./d1/d2/f2_2.js
./d1/f1_1.js
./d1/f1_2.js
root#i5-cpu:~/work_area/php# tar -tvf tar.tar
-rw-rw-rw- root/root 0 2019-01-17 01:12 f2_1.js
-rw-rw-rw- root/root 0 2019-01-17 01:12 f2_2.js
-rw-rw-rw- root/root 0 2019-01-17 01:11 f1_1.js
-rw-rw-rw- root/root 0 2019-01-17 01:11 f1_2.js
Check this page https://www.gnu.org/software/tar/manual/html_section/tar_51.html
The examples with --transform

How to take backup of a file using find command

I have a file "backup". I want to find that particular file and take a backup with cp command and the backup file will be "backup_b".
The code which i am executing is below
find /u01/app/gafmbs/backup_b -exec cp backup_b backup
But this is not working. How will i do that? Can anybody help me out?
You are not invoking find correctly.
A fix:
find /u01/app/gafmbs -name backup_b -exec cp {} backup \;
^ ^ ^ ^
| | | |
where to look | | exec command terminator
what to look for |
paths to found files

nginx configuration index.html different path

I'm going crazy with the nginx configuration.
I have this directory tree
site
|-- .tmp
| +-- partials
| | |-- partial.js
| | |
| +-- serve
| +-- app
| | |-- app.css
| |
| |-- index.html
|
+-- libs
| +-- folder_a
| |
| +-- folder_b
|
+-- transpiled
| +-- app
| | |-- app.js
Also in my index.html I have the paths like
<script src="../bower_components/jquery/dist/jquery.js"></script>
<script src="app/app.js"></script>
So, if I'm right, my root should be the transpiled directory.
What is a valid nginx configuration for serving my site ?
conf example added
http {
server {
location / {
root html/my_site;
index .tmp/serve/index.html;
try_files $uri transpiled/$uri;
}
}
}
I don't know nginx but i have read something about try_files.
try_files directive should search the file $uri into transpiled/$uri.
So if i have app/app.js try files should search the file in transpiled/app/app.js
This won't work

Resources