Skip to content

Commit 5c0ce21

Browse files
update csv
1 parent 6a2cf8a commit 5c0ce21

17 files changed

+198
-2
lines changed

.gitignore

+12
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
in
2+
test/index.html
3+
index.html
4+
test2.txt
5+
reactphp
6+
whois-registrar
7+
*/out.csv
8+
bash
9+
apimacro
10+
grabwhois
11+
reactphp/
12+
.idea
113
# Logs
214
logs
315
*.log

CNAME

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
bash.letcsv.com

README.md

+71-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,71 @@
1-
# bash
2-
bash.letcsv.com
1+
# [bash.letcsv.com](http://bash.letcsv.com)
2+
3+
## About
4+
5+
6+
## How to start
7+
8+
git clone https://github.com/letcsv/bash
9+
10+
or just tag function:
11+
12+
curl https://bash.letcsv.com/tag.sh
13+
14+
## START
15+
16+
get title tag from file: index.html
17+
18+
```bash
19+
cat index.html | ./tag.sh title
20+
```
21+
22+
OUTPUT:
23+
24+
Softreck | Leadership Through Software Development
25+
26+
27+
## TODO
28+
29+
w ramach projektu apidsl.com
30+
+ zamiast xpath - ładowanie zalezności przez skrypt github
31+
+ letPath - przygotować
32+
https://github.com/letcsv/bash
33+
34+
35+
## TEST
36+
37+
Start tests:
38+
```bash
39+
./test.sh > test1.txt
40+
```
41+
42+
Start tests:
43+
```bash
44+
./test.sh > test2.txt
45+
```
46+
47+
Compare with valid test:
48+
```bash
49+
diff text1.txt test2.txt
50+
```
51+
52+
Check the result:
53+
```bash
54+
cat test2.txt
55+
```
56+
57+
Output:
58+
59+
60+
# TEST
61+
FILE: empty_content.sh
62+
./tag.sh title
63+
OUTPUT:
64+
stdin HTML Content is empty (cat index.html | ./tag.sh title)
65+
66+
# TEST
67+
FILE: empty_tag.sh
68+
cat index.html | ./tag.sh
69+
OUTPUT:
70+
HTML TAG is empty, (e.g.: title, body, header)
71+

_config.yml

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
theme: jekyll-theme-slate

appendCellFromFile.sh

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
if [ ! -t 0 ]; then
3+
IFS='' read -d '' -r INPUT
4+
echo -n "${INPUT}"
5+
echo -n ","
6+
fi
7+
if [ ! -z "$1" ]; then
8+
[ -r "$1" ] && cat $1
9+
fi

appendContentFromFile.sh

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
if [ ! -t 0 ]; then
3+
IFS='' read -d '' -r INPUT
4+
echo -n "${INPUT}"
5+
fi
6+
if [ ! -z "$1" ]; then
7+
[ -r "$1" ] && cat $1
8+
fi

appendToFile.sh

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
[ -t 0 ] && echo "stdin File Content is empty" && exit
3+
IFS='' read -d '' -r CONTENT
4+
[ -z "$1" ] && echo "FILENAME is empty" && exit
5+
FILENAME=$1
6+
PATH_FILE="${FILENAME}"
7+
( [ -e "${PATH_FILE}" ] || touch "${PATH_FILE}" ) && [ ! -w "${PATH_FILE}" ] && echo "CONTENT can not be written to FILE: ${PATH_FILE}" && exit
8+
#echo "${CONTENT}"
9+
#echo "${PATH_FILE}"
10+
echo -n "${CONTENT}" >> "${PATH_FILE}"

appendToFileAsNewLine.sh

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
[ -t 0 ] && echo "stdin File Content is empty" && exit
3+
IFS='' read -d '' -r CONTENT
4+
[ -z "$1" ] && echo "FILENAME is empty" && exit
5+
FILENAME=$1
6+
PATH_FILE="${FILENAME}"
7+
( [ -e "${PATH_FILE}" ] || touch "${PATH_FILE}" ) && [ ! -w "${PATH_FILE}" ] && echo "CONTENT can not be written to FILE: ${PATH_FILE}" && exit
8+
#echo "${CONTENT}"
9+
#echo "${PATH_FILE}"
10+
echo "${CONTENT}" >> "${PATH_FILE}"

createFile.sh

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
FILENAME=$1
3+
CONTENT=
4+
[ ! -t 0 ] && IFS='' read -d '' -r CONTENT
5+
[ -z "$FILENAME" ] && FILENAME=$CONTENT
6+
[ -z "$FILENAME" ] && [ -z "$CONTENT" ] && echo "input data is empty" && exit
7+
#
8+
echo -n "$CONTENT" > $FILENAME
9+
#if [ ! -z "$FILENAME" ] && [ -z "$CONTENT" ]; then
10+
# touch "${FILENAME}"
11+
#else
12+
# echo -n "$CONTENT" > $FILENAME
13+
#fi

filename.txt

Whitespace-only changes.

test.sh

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
## prepare example of file: index.html
3+
curl "https://softreck.com" --silent -o index.html
4+
echo ""
5+
6+
## Test
7+
TEST_FILE_LIST=$(ls test)
8+
for FILE in $TEST_FILE_LIST
9+
do
10+
echo "# TEST"
11+
echo "FILE: $FILE"
12+
cat test/$FILE
13+
echo ""
14+
echo "OUTPUT:"
15+
sh test/$FILE
16+
echo ""
17+
done

test/appendCellFromFile.sh

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/bash
2+
echo -n "one" | ./appendCellFromFile.sh "text.txt"

test/appendContentFromFile.sh

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/bash
2+
echo -n "one" | ./appendContentFromFile.sh "text.txt"

test/appendToFile.sh

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
echo "text" | ./appendToFile.sh "filename.txt"
3+
./appendToFile.sh "filename.txt"

test/createFile.sh

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
echo "text" | ./createFile.sh "filename.txt"
3+
./createFile.sh "filename.txt"
4+
./createFile.sh
5+
cat "filename.txt"

test1.txt

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
2+
# TEST
3+
FILE: appendCellFromFile.sh
4+
#!/bin/bash
5+
echo -n "one" | ./appendCellFromFile.sh "text.txt"
6+
OUTPUT:
7+
one,text
8+
9+
# TEST
10+
FILE: appendContentFromFile.sh
11+
#!/bin/bash
12+
echo -n "one" | ./appendContentFromFile.sh "text.txt"
13+
OUTPUT:
14+
onetext
15+
16+
# TEST
17+
FILE: appendToFile.sh
18+
#!/bin/bash
19+
echo "text" | ./appendToFile.sh "filename.txt"
20+
./appendToFile.sh "filename.txt"
21+
OUTPUT:
22+
stdin File Content is empty
23+
24+
# TEST
25+
FILE: createFile.sh
26+
#!/bin/bash
27+
echo "text" | ./createFile.sh "filename.txt"
28+
./createFile.sh "filename.txt"
29+
./createFile.sh
30+
cat "filename.txt"
31+
OUTPUT:
32+
input data is empty
33+

text.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
text

0 commit comments

Comments
 (0)