Code: Select all
#!/bin/bash
file=$1
expression=$2
if [ -z "$file" ] || [ -z "$expression" ]; then
echo "file or expression is missing"
exit 1
fi
grep "$expression" "$file" | cut -d: -f2 | clipit
Code: Select all
#!/bin/bash
file=$1
expression=$2
if [ -z "$file" ] || [ -z "$expression" ]; then
echo "file or expression is missing"
exit 1
fi
grep "$expression" "$file" | cut -d: -f2 | clipit
Code: Select all
#!/bin/bash
file=$2
expression=$1
if [ -z "$file" ] || [ -z "$expression" ]; then
echo "file or expression is missing"
exit 1
fi
grep "$expression" "$file" | cut -d: -f2 | clipit
That's neat. And what is the problem? Are we supposed to run this and debug it for you? If you want help, be more specific.Agvaniot wrote:i am trying to extract the second field from a file and send it to clipit
Code: Select all
echo bla | clipit
clipit bla
Code: Select all
CLI EXAMPLES
Put text in the clipboard
echo "copied to clipboard" | clipit
clipit "copied to clipboard"
Put text in the clipboard and print the clipboard contents
echo "copied to clipboard" | clipit -c