tld-filtering-and-chunking/bin/toclip.sh

37 lines
917 B
Bash
Executable file

#!/bin/bash
# Check if a file name is provided
if [ $# -eq 0 ]; then
echo "Error: No input file specified."
echo "Usage: $0 <input_file>"
exit 1
fi
# Get the script's directory
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# Get the project root directory (one level up from the script directory)
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
# Set the data directory
DATA_DIR="$PROJECT_ROOT/data"
# Get the input file name from the command line argument
INPUT_FILE="$1"
# Construct the full path to the input file
FULL_PATH="$DATA_DIR/$INPUT_FILE"
# Check if the file exists
if [ ! -f "$FULL_PATH" ]; then
echo "Error: File '$FULL_PATH' not found."
exit 1
fi
echo "Processing file: $FULL_PATH"
# Use tail to skip the first line (header) and pipe to copyq
tail -n +2 "$FULL_PATH" | copyq copy -
echo "Contents of $INPUT_FILE (excluding header) have been copied to clipboard."