Thread: Bash troubles

  1. #1
    Registered User Annonymous's Avatar
    Join Date
    Apr 2011
    Location
    Jackson, New Jersey, United States
    Posts
    302

    Bash troubles

    This script I wrote has some unexpected behavior.

    Code:
    #!/bin/bash
    
    bashts=$(ls -l /bin/bash | awk '{print $7}' | sed 's/\://g');
    
    readarray array < <(ls -l | awk '{ print $7" "$8}'; 
    echo "${array[@]}" | sed -e 's/\://g; s/^[ \t]*//'); 
    
    for i in "${array[@]}"; do  
    
    	if [[ "$i" > "$bashts" ]] ; then 
    	  echo $i | grep -v "~" | awk '{print $2}'; 
    
      fi 
    
    done
    It copies the all of the contents from the directory I run it in, to all ascending dirs that have initalized git repos in them.

    What it does is compare how long I have I have had the shell open, against all files in that directory. So any file that has been modified since I have opened the shell, will be displayed to stdout.

    ANYONE KNOW THE CAUSE?

    What i am actually doing is writing a CL automation script for github.

    I also wrote a script for a recursive touch function. It recursively touches all fles in any dir that has an initialized git repo. Then updates the terminals time stamp as well. On every reboot/boot.

    Code:
    #!/bin/bash
    
    sudo touch /bin/bash
    
    readarray -t paths < <(find ~ -iname ".git" | sed -e 's/^[.]*//; s/.git//g'); 
    
    readarray -t files < <(ls -l | awk '{print $8}' | grep -v "~")
    
    	for f in "${paths[@]}"; do
    	cd "$f"
    
    	  for i in "${files[@]}"; do 
    	  sudo touch "$i" 
      done
    
    done
    
    sudo touch /bin/bash
    So I hope you can see what I am trying to accomplish and can tell my why my script is doing this copying non-sense. Thanks
    Last edited by Annonymous; 09-23-2012 at 11:15 PM.

  2. #2
    Registered User Annonymous's Avatar
    Join Date
    Apr 2011
    Location
    Jackson, New Jersey, United States
    Posts
    302
    fixed the problem.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. popen and /bin/bash -c
    By TuXaKoS in forum C Programming
    Replies: 25
    Last Post: 05-01-2010, 06:24 PM
  2. A bash question
    By lehe in forum Linux Programming
    Replies: 9
    Last Post: 07-29-2009, 12:43 AM
  3. Can't run Bash!
    By Yarin in forum Tech Board
    Replies: 3
    Last Post: 05-11-2009, 07:25 PM
  4. Help set gvim bash
    By glo in forum Tech Board
    Replies: 3
    Last Post: 04-04-2008, 07:44 AM
  5. What company to bash..?
    By h_howee in forum A Brief History of Cprogramming.com
    Replies: 74
    Last Post: 02-03-2008, 01:13 PM