Results 1 to 6 of 6

Thread: Bash Variable loops?

  1. #1
    Join Date
    2015-Mar
    Posts
    12

    Talking Bash Variable loops?

    Im not sure how to explain this cause Ima noob (so bare with me)
    i have this script
    Code:
    #!/bin/bash
    1 = adobe_reader.cache
    2 = dobe_reader.mru
    3 = adobe_reader.tmp
    4 = apt.autoclean
    5 = apt.autoremove
    6 = apt.clean
    7 = bash.history
    8 = deepscan.backup
    9 = deepscan.ds_store
    10 = deepscan.thumbs_db
    11 = deepscan.tmp
    12 = exaile.cache
    13 = exaile.downloaded_podcasts
    14 = exaile.log
    15 = filezilla.mru
    16 = firefox.cache
    17 = firefox.cookies
    18 = firefox.crash_reports
    19 = firefox.dom
    20 = firefox.download_history
    21 = firefox.forms
    22 = firefox.passwords
    23 = firefox.session_restore
    24 = firefox.site_preferences
    25 = firefox.url_history
    26 = firefox.vacuum
    27 = flash.cache
    28 = flash.cookies
    29 = gedit.recent_documents
    30 = gftp.cache
    31 = gftp.logs
    32 = gimp.tmp
    33 = gl-117.debug_logs
    34 = gnome.run
    35 = gnome.search_history
    36 = gpodder.cache
    37 = gpodder.vacuum
    38 = gwenview.recent_documents
    39 = hippo_opensim_viewer.cache
    40 = hippo_opensim_viewer.logs
    41 = java.cache
    42 = libreoffice.cache
    43 = libreoffice.history
    44 = links2.history
    45 = midnightcommander.history
    46 = miro.cache
    47 = miro.logs
    48 = nautilus.history
    49 = nexuiz.cache
    50 = openofficeorg.cache
    51 = openofficeorg.recent_documents
    52 = realplayer.cookies
    53 = realplayer.history
    54 = realplayer.logs
    55 = recoll.index
    56 = system.cache
    57 = system.clipboard
    58 = system.desktop_entry
    59 = system.free_disk_space
    60 = system.localizations
    61 = system.memory
    62 = system.recent_documents
    63 = system.rotated_logs
    64 = system.tmp
    65 = system.trash
    66 = tremulous.cache
    67 = vim.history
    68 = vlc.mru
    69 = wine.tmp
    70 = winetricks.temporary_files
    71 = x11.debug_logs
    72 = xchat.logs
    73 = xine.cache
    for i in [1..73]
    	do 
    		bleachbit --clean "$"$i""
    done
    It is to run all cleaners for bleachbit one at a time from within a for loop
    ive tried to asign each cleaner string to a variable number 1-73
    then acces the cleaners variable number with $i
    but it just spits out
    1 command not found
    2 command not found
    3 command not found
    etc etc
    i've tried several different modifications to the "$"$i"" part
    $"$i", '$"$i" just to name a couple
    but nothing seems to make it work how i plan
    any help you have to offer would be great
    ReVoCaTiOn !!!!!!!!!!!!!!!!!!!!!!!

  2. #2
    Join Date
    2013-Mar
    Location
    milano
    Posts
    301
    hi :-)
    I state not to know the bash-scripting .. && I do not know 'if it is written correctly && works correctly... but if this ""ESCAMOTAGE"" can be a help-to-solve:
    http://postimg.org/image/wjer48wwn/full/

  3. #3
    Join Date
    2014-Apr
    Location
    Down Under
    Posts
    315
    I didn't notice that you are not using all the clean options. I made one which will run clean on everything bleachbit offers but I'm out of time

    Code:
    #!/bin/bash
    
    for i in $(bleachbit -l | sed '1,1d'); do bleachbit --clean $i; done;
    chown -R us ./base

  4. #4
    Join Date
    2014-Apr
    Location
    Down Under
    Posts
    315
    I guess I did have time... This will do what you want without the need of an external list.

    Code:
    #!/bin/bash
    
    options=(adobe_reader.cache \
    dobe_reader.mru \
    adobe_reader.tmp \
    apt.autoclean \
    apt.autoremove \
    apt.clean \
    bash.history \
    deepscan.backup \
    deepscan.ds_store \
    deepscan.thumbs_db \
    deepscan.tmp \
    exaile.cache \
    exaile.downloaded_podcasts \
    exaile.log \
    filezilla.mru \
    firefox.cache \
    firefox.cookies \
    firefox.crash_reports \
    firefox.dom \
    firefox.download_history \
    firefox.forms \
    firefox.passwords \
    firefox.session_restore \
    firefox.site_preferences \
    firefox.url_history \
    firefox.vacuum \
    flash.cache \
    flash.cookies \
    gedit.recent_documents \
    gftp.cache \
    gftp.logs \
    gimp.tmp \
    gl-117.debug_logs \
    gnome.run \
    gnome.search_history \
    gpodder.cache \
    gpodder.vacuum \
    gwenview.recent_documents \
    hippo_opensim_viewer.cache \
    hippo_opensim_viewer.logs \
    java.cache \
    libreoffice.cache \
    libreoffice.history \
    links2.history \
    midnightcommander.history \
    miro.cache \
    miro.logs \
    nautilus.history \
    nexuiz.cache \
    openofficeorg.cache \
    openofficeorg.recent_documents \
    realplayer.cookies \
    realplayer.history \
    realplayer.logs \
    recoll.index \
    system.cache \
    system.clipboard \
    system.desktop_entry \
    system.free_disk_space \
    system.localizations \
    system.memory \
    system.recent_documents \
    system.rotated_logs \
    system.tmp \
    system.trash \
    tremulous.cache \
    vim.history \
    vlc.mru \
    wine.tmp \
    winetricks.temporary_files \
    x11.debug_logs \
    xine.cache)
    
    for i in ${options[@]}; do
    	bleachbit --clean $i
    
    done
    exit 0
    chown -R us ./base

  5. #5
    Join Date
    2013-Mar
    Location
    milano
    Posts
    301

    Red face

    Quote Originally Posted by staticn0de View Post
    I guess I did have time... This will do what you want without the need of an external list.

    Code:
    #!/bin/bash
    
    options=(adobe_reader.cache \
    dobe_reader.mru \
    adobe_reader.tmp \
    apt.autoclean \
    apt.autoremove \
    apt.clean \
    bash.history \
    deepscan.backup \
    deepscan.ds_store \
    deepscan.thumbs_db \
    deepscan.tmp \
    exaile.cache \
    exaile.downloaded_podcasts \
    exaile.log \
    filezilla.mru \
    firefox.cache \
    firefox.cookies \
    firefox.crash_reports \
    firefox.dom \
    firefox.download_history \
    firefox.forms \
    firefox.passwords \
    firefox.session_restore \
    firefox.site_preferences \
    firefox.url_history \
    firefox.vacuum \
    flash.cache \
    flash.cookies \
    gedit.recent_documents \
    gftp.cache \
    gftp.logs \
    gimp.tmp \
    gl-117.debug_logs \
    gnome.run \
    gnome.search_history \
    gpodder.cache \
    gpodder.vacuum \
    gwenview.recent_documents \
    hippo_opensim_viewer.cache \
    hippo_opensim_viewer.logs \
    java.cache \
    libreoffice.cache \
    libreoffice.history \
    links2.history \
    midnightcommander.history \
    miro.cache \
    miro.logs \
    nautilus.history \
    nexuiz.cache \
    openofficeorg.cache \
    openofficeorg.recent_documents \
    realplayer.cookies \
    realplayer.history \
    realplayer.logs \
    recoll.index \
    system.cache \
    system.clipboard \
    system.desktop_entry \
    system.free_disk_space \
    system.localizations \
    system.memory \
    system.recent_documents \
    system.rotated_logs \
    system.tmp \
    system.trash \
    tremulous.cache \
    vim.history \
    vlc.mru \
    wine.tmp \
    winetricks.temporary_files \
    x11.debug_logs \
    xine.cache)
    
    for i in ${options[@]}; do
    	bleachbit --clean $i
    
    done
    exit 0
    @staticn0de
    thanks a lot of explanation !!!!
    also it serves to me! +1

  6. #6
    Join Date
    2015-Mar
    Posts
    12
    Thanks so much everybody
    i see now i was just thinking of the hardest possible solution to an easy problem
    yall are awesome
    ReVoCaTiOn !!!!!!!!!!!!!!!!!!!!!!!

Similar Threads

  1. wifite loops back when selecting adapter for monitor mode
    By donThomaso in forum NetHunter General Questions
    Replies: 1
    Last Post: 2017-01-07, 18:15
  2. Replies: 0
    Last Post: 2016-10-07, 03:47

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •