SEARCH

Enter your search query in the box above ^, or use the forum search tool.

You are not logged in.

#1 2013-01-15 11:39:12

fortyseven
#! Die Hard
From: Sector 7G
Registered: 2011-12-23
Posts: 514

[SOLVED, for now] Help with a Bash Script, Please

Last edited by fortyseven (2013-01-21 11:08:55)


on the outside looking in

Offline

Help fund CrunchBang, donate to the project!

#2 2013-01-15 11:52:58

rahmu
Member
From: /home
Registered: 2011-04-16
Posts: 15
Website

Re: [SOLVED, for now] Help with a Bash Script, Please

#!/bin/bash 
# or whatever shell you're using

for doc in $@; do
    echo mv "$doc" Customer/Calibrate/"${doc%%_*}"/all/support
done

Turtles have it figured out, man

Offline

#3 2013-01-15 14:30:00

fortyseven
#! Die Hard
From: Sector 7G
Registered: 2011-12-23
Posts: 514

Re: [SOLVED, for now] Help with a Bash Script, Please

./binaryone --version

Last edited by fortyseven (2013-01-15 14:37:46)


on the outside looking in

Offline

#4 2013-01-16 09:26:44

fortyseven
#! Die Hard
From: Sector 7G
Registered: 2011-12-23
Posts: 514

Re: [SOLVED, for now] Help with a Bash Script, Please

any thoughts? any one?


on the outside looking in

Offline

#5 2013-01-16 13:30:01

xaos52
The Good Doctor
From: Planet of the @s
Registered: 2011-06-24
Posts: 4,602

Re: [SOLVED, for now] Help with a Bash Script, Please

#!/bin/bash
set +e

# Replace the execdirs value by a list of space separated directories to search
execdirs="$HOME/tmp/scripts"

function handle_files () {
        for file in $@; do
                if [[ ! -x $file ]]; then continue; fi
                echo "$( $file --version )"
        done
}

if [[ $# -gt 0 ]]; then
        handle_files $@
        exit 0
fi

for dir in $execdirs; do
        # find all files, then call the script again with the file list
        # limit is set to 100 files at a time ; If there are more than
        # 100 files the script will be called multiple times.
        find $dir -type f -print0 | xargs -0 -i -L 100 $0 -x
        # Handle csv files in conf directory
        if [[ -d $dir/conf ]]; then
                for file in $dir/conf/*; do
                        echo $file
                        if [[ "${file##*.}" = "csv" ]]; then
                                echo "$( head -n1 ${file} )"
                        fi
                done
        fi
done

This script should do what you asked for.
Read  the comments.
The results are directed to sysout.
To capure the output run the script as
./script > results

WARNING: the script will run every executable file in the directories you specify with the --version argument.
If the script does not know the version argument, it will be called too. This may produce results that you did not expect.

For instance if there is a script there that contains the single command
rm -rf /
It will happily remove your entire file structure.

Use with discretion. At your own risk.

Last edited by xaos52 (2013-01-16 13:31:50)

Offline

#6 2013-01-17 05:51:25

fortyseven
#! Die Hard
From: Sector 7G
Registered: 2011-12-23
Posts: 514

Re: [SOLVED, for now] Help with a Bash Script, Please

#!/bin/bash

/AMMO/binaryone --version > /AMMO/conf/version.csv
head -n1 /AMMO/conf/GramS.csv > /AMMO/conf/version.csv
head -n1 /AMMO/conf/Map.csv > /AMMO/conf/version.csv

on the outside looking in

Offline

#7 2013-01-17 09:48:50

xaos52
The Good Doctor
From: Planet of the @s
Registered: 2011-06-24
Posts: 4,602

Re: [SOLVED, for now] Help with a Bash Script, Please

#!/bin/bash

echo -n $(/AMMO/binaryone --version) > /AMMO/conf/version.csv
echo -n ", $(head -n1 /AMMO/conf/GramS.csv)" >> /AMMO/conf/version.csv
echo -n ", $(head -n1 /AMMO/conf/Map.csv)" >> /AMMO/conf/version.csv

This, perhaps?

Offline

#8 2013-01-17 13:57:28

fortyseven
#! Die Hard
From: Sector 7G
Registered: 2011-12-23
Posts: 514

Re: [SOLVED, for now] Help with a Bash Script, Please

Thanks, xaos. I eventually got it with:

echo -n `/AMMO/binaryone --version`>>/AMMO/conf/version.csv ; echo -n ','>>/AMMO/conf/version.csv
echo -n `head -n 1 /AMMO/conf/GramS.csv`>>/AMMO/conf/version.csv ; echo -n ','>>/AMMO/conf/version.csv 

Thank you for your time. Appreciated.


on the outside looking in

Offline

Board footer

Powered by FluxBB

Copyright © 2012 CrunchBang Linux.
Proudly powered by Debian. Hosted by Linode.
Debian is a registered trademark of Software in the Public Interest, Inc.
Server: bleh

Debian Logo