-
Notifications
You must be signed in to change notification settings - Fork 2
/
csv-search
37 lines (27 loc) · 830 Bytes
/
csv-search
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/bin/bash
# File containing the book information
csv_file="books.csv"
# Check if the CSV file exists
if [ ! -f "$csv_file" ]; then
echo "Error: The CSV file '$csv_file' does not exist."
exit 1
fi
# Read the CSV file line by line
while IFS=, read -r title author format language; do
# Skip the header line
if [ "$title" != "title" ]; then
command="echo \"$title\" | ./book-scraping-fzf"
if [ -n "$author" ]; then
command="$command --author \"$author\""
fi
if [ -n "$format" ]; then
command="$command --$format"
fi
if [ -n "$language" ]; then
command="$command --$language"
fi
echo "Search: $title"
eval "$command"
fi
done < "$csv_file"
echo "Search completed for all books."