Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

script not working

New to Debian (Or Linux in general)? Ask your questions here!
Post Reply
Message
Author
Agvaniot
Posts: 42
Joined: 2017-07-26 13:07

script not working

#1 Post by Agvaniot »

i am trying to extract the second field from a file and send it to 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


Agvaniot
Posts: 42
Joined: 2017-07-26 13:07

Re: script not working

#2 Post by Agvaniot »

EDITED IMPROVED VERESION

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

kopper
Posts: 137
Joined: 2016-09-30 14:30

Re: script not working

#3 Post by kopper »

Agvaniot wrote:i am trying to extract the second field from a file and send it to 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.

Since I can only guess, here's a shot in the dark.. 1) You don't need quotation marks to use the variables after grep. 2) In what order are you trying to give the arguments? You declare file as first variable, and expression second. However you have it other way around in your actual command. Ensure that you're passing the arguments in right order when you execute your script.

I think the reason for lack of replies in this thread is that everybody have better use for their time than playing "Guess who" with you.
Debian 10.2 Stable with i3
Secure your stuff: Securing Debian Manual
Don't break your stuff: Source List Management DontBreakDebian

User avatar
debiman
Posts: 3063
Joined: 2013-03-12 07:18

Re: script not working

#4 Post by debiman »

i tend to agree with the previous poster, but i use clipit and it was easy for me to test:

Code: Select all

echo bla | clipit
clipit bla
this feature does NOT work although advertised in the man page:

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
there are, however, other applications that can put text in the clipboard.
xclip.

Post Reply