Skip to content

Commit

Permalink
Remove debug info and add examples to README
Browse files Browse the repository at this point in the history
  • Loading branch information
gflegar committed Aug 27, 2018
1 parent 3b4b600 commit f8db547
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 3 deletions.
61 changes: 61 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,67 @@ Available options:
Calling ssget without arguments is equivalent to: ssget -i 0 -t MM -v
```

Examples
--------


### Example 1

Return properties of all matrices as a JSON array:

```sh
NUM_PROBLEMS=$(ssget -n)

echo "["
for (( i=1; i <= ${NUM_PROBLEMS}; ++i )); do
ssget -i $i -j
echo ","
done
echo "]"
```


### Example 2

Download matrix arhives for the entire collection, and print the size:

```sh
NUM_PROBLEMS=$(ssget -n)

TOTAL_SIZE=0

for (( i=1; i <= ${NUM_PROBLEMS}; ++i )); do
# ssget -i $i -j
ARCHIVE=$(ssget -i $i -f)
SIZE=($(du -k ${ARCHIVE}))
echo "${ARCHIVE}: ${SIZE}KB"
TOTAL_SIZE=$((${TOTAL_SIZE} + ${SIZE}))
done

echo "Total: ${TOTAL_SIZE}KB"
```

__NOTE:__ This will transfer and store a huge amount of data!


### Example 3
Extract (and download if needed) the matrix with ID=10, pass its location to
the program `foo` and delete the extracted files (but keep the archive)
afterwards:

```sh
foo $(ssget -ei10)
ssget -ci10
```

### Example 4
Delete the archive for matrix with ID=10

```sh
ssget -ri10
```

License
-------
BSD 3-clause

9 changes: 6 additions & 3 deletions ssget
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,14 @@ download_info() {
}


PROPS=""
get_properties() {
download_info
head -$((${MATRIX_ID} + 2)) "${ARCHIVE_LOCATION}/ssstats.csv" | tail -1
if [ "${PROPS}" == "" ]; then
PROPS=$(head -$((${MATRIX_ID} + 2)) "${ARCHIVE_LOCATION}/ssstats.csv" \
| tail -1)
fi
echo ${PROPS}
}


Expand Down Expand Up @@ -135,8 +140,6 @@ EOT

download_archive() {
PATH_INFO=($(get_path_info))
echo "${PATH_INFO[@]}"

if [ ! -f ${PATH_INFO[4]} ]; then
curl -Lo ${PATH_INFO[4]} ${PATH_INFO[3]}
fi
Expand Down

0 comments on commit f8db547

Please sign in to comment.