WebI quick and ugly (and not foolproof) way would be to limit the number of directory separators, for example: $ tar tvf myfile.tar grep -E '^ [^/]* (/ [^/]*) {1,2}$' The 2 tells to display not more than 2 slashes (in my case one is already generated by the user/group separator), and hence, to display files at depth at most one. WebFeb 7, 2014 · Add the -C option (or --directory, it is the same): tar –xzf filename.tgz -C /target/directory From man tar: -C, --directory DIR change to directory DIR Share Improve this answer Follow answered Feb 7, 2014 at 9:16 fedorqui 270k 102 541 593 1 watch out for tar bombs and you probably want to add v to your list of flags. – user2485710
Tar a directory, but don
WebUse the -C switch of tar: tar -czvf my_directory.tar.gz -C my_directory . The -C my_directory tells tar to change the current directory to … WebSep 18, 2024 · To tar a file in linux, first open a terminal. Then, navigate to the directory that contains the file you wish to tar. To tar the file, type “tar -czvf name_of_file.tar.gz … tendou maya mbti
How do I Compress a Whole Linux or UNIX Directory? - nixCraft
WebFeb 2, 2024 · Add a comment 1 Answer Sorted by: 1 Since it is a jenkinsFile you can use: tar file: 'your-files.tar.gz', dir: 'your-files-dir' More info in the documentation: … WebCreate a tar archive tar czf $sourcedir/$backup_dir.tar --directory=$sourcedir -INF en Un-tar files on a local machine tar -xvf $deploydir/med365/$backup_dir.tar -C $deploydir/med365/ Upload to a server scp -r -i $privatekey $sourcedir/$backup_dir.tar $server:$deploydir/med365/ echo "File uploaded.. deployment folders" Un-tar on server WebDec 4, 2015 · The correct command is tar cvf - /path/dirtocompress gzip > myarchive.tar.gz This will compress the directory into one gzip file. As suggested by patrix, you can verify the paths are being stored correctly in this file using the following command which lists the contents of the file to stdout: gunzip -c myarchive.tar.gz tar -tvf - tendou manga panels