<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: cdworkcd</title>
    <description>The latest articles on DEV Community by cdworkcd (@bcd).</description>
    <link>https://dev.to/bcd</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F895824%2Ff88b3381-7a7f-47c9-bdc8-44b7d05079ce.png</url>
      <title>DEV Community: cdworkcd</title>
      <link>https://dev.to/bcd</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/bcd"/>
    <language>en</language>
    <item>
      <title>Sudden permission problem in Ubuntu</title>
      <dc:creator>cdworkcd</dc:creator>
      <pubDate>Thu, 28 Jul 2022 06:08:00 +0000</pubDate>
      <link>https://dev.to/bcd/sudden-permission-problem-in-ubuntu-2jc1</link>
      <guid>https://dev.to/bcd/sudden-permission-problem-in-ubuntu-2jc1</guid>
      <description>&lt;p&gt;Hi,&lt;br&gt;
I have Ubunto on Win 10.&lt;br&gt;
(It's connect with wsl)&lt;br&gt;
always- everything woeked well.&lt;br&gt;
this morning I opened the Terminal and typed in the root &lt;code&gt;mkdir some&lt;/code&gt; &lt;br&gt;
and got: &lt;strong&gt;mkdir: cannot create directory ‘some’: Permission denied&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--TAldQJ9t--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lvziaqn5ko8apq19wq6t.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--TAldQJ9t--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lvziaqn5ko8apq19wq6t.png" alt="Image description" width="690" height="59"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;and when I did &lt;code&gt;ls&lt;/code&gt; I got only folders and files of installations whithout the folders and the files I created.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--92zJp_mK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cswoum4aczjp7v5rfxp0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--92zJp_mK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cswoum4aczjp7v5rfxp0.png" alt="Image description" width="880" height="41"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If anyone knows what the problem is- Itll help me a lot&lt;br&gt;
thanks&lt;/p&gt;

</description>
    </item>
    <item>
      <title>unpack tar doesn't work for me in the script but it does in Terminal</title>
      <dc:creator>cdworkcd</dc:creator>
      <pubDate>Thu, 21 Jul 2022 20:19:00 +0000</pubDate>
      <link>https://dev.to/bcd/unpack-tar-doesnt-work-for-me-in-the-script-but-it-does-in-terminal-5701</link>
      <guid>https://dev.to/bcd/unpack-tar-doesnt-work-for-me-in-the-script-but-it-does-in-terminal-5701</guid>
      <description>&lt;p&gt;If possible I have a question:&lt;br&gt;
this what I did in the Terminal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ tar cvf compress.tar jenkinsfile
jenkinsfile
$ ls
compress.tar  jenkinsfile
$ rm jenkinsfile
$ ls
compress.tar
$ tar --overwrite -xvf compress.tar
jenkinsfile
$ ls
compress.tar  jenkinsfile
$
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It works fine- the file jenkinsfile unpacked. and this is my script: (&lt;code&gt;"$1"&lt;/code&gt; = compress.tar in this case)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;...
function func_decompress(){
    check=0
    case $1 in
    *.tar.gz | *.tar | *.tar.bz2)
        check=1
        tar --overwrite -xvf "$1" 
        rm "$1" ;;
    *.zip)
        check=1
        unzip -o "$1"
        rm "$1" ;;
    *.bz2)
        check=1
        bunzip2 "$1" ;;
    *.gz)
        check=1
        gunzip "$1" ;;
    esac
    if [ $check == 0 ]
    then
        uncompressPrintFunc "$1"
    else
        compressPrintFunc "$1"
    fi
}
...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ ./bcd.sh -v -r bcd
Ignoring 3077ed8635670985d31fdbf043bd3d60.jpg ...
jenkinsfile
Unpacking compress.tar ...
Ignoring jenkinsfile ...
Ignoring file.txt ...
Ignoring file1.txt ...
Ignoring file2.txt ...
Decompressed 1
(failure for 5 files)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;this is the Terminal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ ls
compress.tar  jenkinsfile
$ rm jenkinsfile
$ ls
compress.tar
$ cd ../..
bcdbcdbcdbcdbcdbcdbcdbcdbcdbcdbcdbcdbcdbcdbcdbcdbcdbcdbcdbcdbcd$ ./bcd.sh -v -r bcd
Ignoring 3077ed8635670985d31fdbf043bd3d60.jpg ...
jenkinsfile
Unpacking compress.tar ...
Ignoring file.txt ...
Ignoring file1.txt ...
Ignoring file2.txt ...
Decompressed 1
(failure for 4 files)
bcdbcdbcdbcdbcdbcdbcdbcdbcdbcdbcdbcdbcdbcdbcdbcdbcdbcdbcdbcdbcd$ cd bcd/bcdbcdbcd/
$ ls
$
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;ps This is all my script:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#! /usr/bin/bash

array=($@)
new_array=()
for value in "${array[@]}"
do
    [[ $value != '-r' &amp;amp;&amp;amp; $value != '-v' ]] &amp;amp;&amp;amp; new_array+=($value)
done
array=("${new_array[@]}")
unset new_array

count_compress_files=0
count_uncompress_files=0
option_r=false
option_v=false

while getopts "rv" opt; do
    case $opt in
        r)  
            option_r=true
            ;;  
        v)  
            option_v=true
            ;;  
    esac
done

function func_recursive() 
{
            array=()
            while IFS=  read -r -d $'\0'; do
                array+=("$REPLY")
            done &amp;lt; &amp;lt;(find $1 -type f -follow -print0)
            for i in "${array[@]}"
            do
                func_decompress "$i"
            done   
}

function func_decompress(){
    check=0
    case $1 in
    *.tar.gz | *.tar | *.tar.bz2)
        check=1
        tar -c -xvf "$1" 
        rm "$1" ;;
    *.zip)
        check=1
        unzip -o "$1"
        rm "$1" ;;
    *.bz2)
        check=1
        bunzip2 "$1" ;;
    *.gz)
        check=1
        gunzip "$1" ;;
    esac
    if [ $check == 0 ]
    then
        uncompressPrintFunc "$1"
    else
        compressPrintFunc "$1"
    fi
}

function uncompressPrintFunc(){
    if [ $option_v == true ]
        then
            file=$(extraction_func "$1")
            echo "Ignoring $file ..."
        fi
    count_uncompress_files=$(( count_uncompress_files+1 ))
}

function compressPrintFunc(){
    if [ $option_v == true ]
        then
            file=$(extraction_func "$1")
            echo "Unpacking $file ..."
        fi
    count_compress_files=$(( count_compress_files+1 ))
}

function extraction_func(){
    filepath="$1"
    FILE=${filepath##*/}
    echo "$FILE"
}

function func_not_recursive_folder(){
    echo "I am not_recursive_folder"
    echo "check 1: $1"
    i=0
    filepath
    while read line
    do
        filepath=$(realpath -s "$line")
        array[ $i ]="$filepath"        
        (( i++ ))
    done &amp;lt; &amp;lt;(ls $1)
    for packedfile in "${array[@]}"
    do
        func_decompress "$packedfile"
    done

}

for i in "${array[@]}"
do
    bcd=$(find ~+ -name "$i")
    if [[ -d $bcd ]]
    then
        if [ $option_r == true ]
        then
            func_recursive $bcd
        else
            func_not_recursive_folder $bcd
        fi
    elif [[ -f $bcd ]]
    then
        func_decompress $bcd
    else
        echo "This input: $i is not valid!"
        exit 1
    fi
done

echo "Decompressed $count_compress_files"
[[ "$count_uncompress_files" -gt 0 ]] &amp;amp;&amp;amp; echo "(failure for $count_uncompress_files files)" || echo "(success)"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I would appreciate it if someone could help me! Thanks&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
