Linux shell get device id from user input
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
Good day,
So I am working on an install script for a program that needs the device id from lsusb in it's configuration so I was thinking of doing the following:
$usblist=(lsusb)
#put the list into a array for each line.
#use the array to give the user a selection list usinging whiptail.
#from that line strip out the device id and vender id from the selected line.
The line looks as follows:
Bus 001 Device 004: ID 0665:5161 Cypress Semiconductor USB to Serial
So I want only the 9 characters after "IDspace"
Sorry I haven't gotten very far with my code but I am stuck on this and have no idea how to do what I would like to do. Please can someone help. I am very new to shell scripting
linux lsusb
add a comment |Â
up vote
0
down vote
favorite
Good day,
So I am working on an install script for a program that needs the device id from lsusb in it's configuration so I was thinking of doing the following:
$usblist=(lsusb)
#put the list into a array for each line.
#use the array to give the user a selection list usinging whiptail.
#from that line strip out the device id and vender id from the selected line.
The line looks as follows:
Bus 001 Device 004: ID 0665:5161 Cypress Semiconductor USB to Serial
So I want only the 9 characters after "IDspace"
Sorry I haven't gotten very far with my code but I am stuck on this and have no idea how to do what I would like to do. Please can someone help. I am very new to shell scripting
linux lsusb
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
Good day,
So I am working on an install script for a program that needs the device id from lsusb in it's configuration so I was thinking of doing the following:
$usblist=(lsusb)
#put the list into a array for each line.
#use the array to give the user a selection list usinging whiptail.
#from that line strip out the device id and vender id from the selected line.
The line looks as follows:
Bus 001 Device 004: ID 0665:5161 Cypress Semiconductor USB to Serial
So I want only the 9 characters after "IDspace"
Sorry I haven't gotten very far with my code but I am stuck on this and have no idea how to do what I would like to do. Please can someone help. I am very new to shell scripting
linux lsusb
Good day,
So I am working on an install script for a program that needs the device id from lsusb in it's configuration so I was thinking of doing the following:
$usblist=(lsusb)
#put the list into a array for each line.
#use the array to give the user a selection list usinging whiptail.
#from that line strip out the device id and vender id from the selected line.
The line looks as follows:
Bus 001 Device 004: ID 0665:5161 Cypress Semiconductor USB to Serial
So I want only the 9 characters after "IDspace"
Sorry I haven't gotten very far with my code but I am stuck on this and have no idea how to do what I would like to do. Please can someone help. I am very new to shell scripting
linux lsusb
asked May 28 at 7:53
Martinn Roelofse
1
1
add a comment |Â
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
0
down vote
The first errors that I see are.
You wrote $usblist=(lsusb | awk 'print $6')
You need to remove the $
from the start, and add a $
before the (
. Some quotes will also help. i.e.
usblist="$(lsusb | awk 'print $6')"
add a comment |Â
up vote
0
down vote
Just use, this uses awk
to print out the 6th
field which in your case is the ID of the device
usblist="$(lsusb | awk 'print $6')"
So you print any field you want, here are the mapping:
- $1 : Bus
- $2 : 001
- $3 : Device
- $4 : 004:
- $5 : ID
- $6 : 0665:5161
- $7 : Cypress
- $8 : Semiconductor
- $9 : USB
- $10 : to
- $11 : Serial
If you want to print more than one field , such as name , you can do like this
usblist="$(lsusb | awk 'print $7,$8,$9')"
You did not test this.
â ctrl-alt-delor
May 28 at 11:24
Thanks for pointing that out, I corrected it @ctrl-alt-delor
â Arushix
May 29 at 3:27
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
The first errors that I see are.
You wrote $usblist=(lsusb | awk 'print $6')
You need to remove the $
from the start, and add a $
before the (
. Some quotes will also help. i.e.
usblist="$(lsusb | awk 'print $6')"
add a comment |Â
up vote
0
down vote
The first errors that I see are.
You wrote $usblist=(lsusb | awk 'print $6')
You need to remove the $
from the start, and add a $
before the (
. Some quotes will also help. i.e.
usblist="$(lsusb | awk 'print $6')"
add a comment |Â
up vote
0
down vote
up vote
0
down vote
The first errors that I see are.
You wrote $usblist=(lsusb | awk 'print $6')
You need to remove the $
from the start, and add a $
before the (
. Some quotes will also help. i.e.
usblist="$(lsusb | awk 'print $6')"
The first errors that I see are.
You wrote $usblist=(lsusb | awk 'print $6')
You need to remove the $
from the start, and add a $
before the (
. Some quotes will also help. i.e.
usblist="$(lsusb | awk 'print $6')"
answered May 28 at 11:23
ctrl-alt-delor
8,75831947
8,75831947
add a comment |Â
add a comment |Â
up vote
0
down vote
Just use, this uses awk
to print out the 6th
field which in your case is the ID of the device
usblist="$(lsusb | awk 'print $6')"
So you print any field you want, here are the mapping:
- $1 : Bus
- $2 : 001
- $3 : Device
- $4 : 004:
- $5 : ID
- $6 : 0665:5161
- $7 : Cypress
- $8 : Semiconductor
- $9 : USB
- $10 : to
- $11 : Serial
If you want to print more than one field , such as name , you can do like this
usblist="$(lsusb | awk 'print $7,$8,$9')"
You did not test this.
â ctrl-alt-delor
May 28 at 11:24
Thanks for pointing that out, I corrected it @ctrl-alt-delor
â Arushix
May 29 at 3:27
add a comment |Â
up vote
0
down vote
Just use, this uses awk
to print out the 6th
field which in your case is the ID of the device
usblist="$(lsusb | awk 'print $6')"
So you print any field you want, here are the mapping:
- $1 : Bus
- $2 : 001
- $3 : Device
- $4 : 004:
- $5 : ID
- $6 : 0665:5161
- $7 : Cypress
- $8 : Semiconductor
- $9 : USB
- $10 : to
- $11 : Serial
If you want to print more than one field , such as name , you can do like this
usblist="$(lsusb | awk 'print $7,$8,$9')"
You did not test this.
â ctrl-alt-delor
May 28 at 11:24
Thanks for pointing that out, I corrected it @ctrl-alt-delor
â Arushix
May 29 at 3:27
add a comment |Â
up vote
0
down vote
up vote
0
down vote
Just use, this uses awk
to print out the 6th
field which in your case is the ID of the device
usblist="$(lsusb | awk 'print $6')"
So you print any field you want, here are the mapping:
- $1 : Bus
- $2 : 001
- $3 : Device
- $4 : 004:
- $5 : ID
- $6 : 0665:5161
- $7 : Cypress
- $8 : Semiconductor
- $9 : USB
- $10 : to
- $11 : Serial
If you want to print more than one field , such as name , you can do like this
usblist="$(lsusb | awk 'print $7,$8,$9')"
Just use, this uses awk
to print out the 6th
field which in your case is the ID of the device
usblist="$(lsusb | awk 'print $6')"
So you print any field you want, here are the mapping:
- $1 : Bus
- $2 : 001
- $3 : Device
- $4 : 004:
- $5 : ID
- $6 : 0665:5161
- $7 : Cypress
- $8 : Semiconductor
- $9 : USB
- $10 : to
- $11 : Serial
If you want to print more than one field , such as name , you can do like this
usblist="$(lsusb | awk 'print $7,$8,$9')"
edited May 29 at 3:21
answered May 28 at 7:56
Arushix
9968
9968
You did not test this.
â ctrl-alt-delor
May 28 at 11:24
Thanks for pointing that out, I corrected it @ctrl-alt-delor
â Arushix
May 29 at 3:27
add a comment |Â
You did not test this.
â ctrl-alt-delor
May 28 at 11:24
Thanks for pointing that out, I corrected it @ctrl-alt-delor
â Arushix
May 29 at 3:27
You did not test this.
â ctrl-alt-delor
May 28 at 11:24
You did not test this.
â ctrl-alt-delor
May 28 at 11:24
Thanks for pointing that out, I corrected it @ctrl-alt-delor
â Arushix
May 29 at 3:27
Thanks for pointing that out, I corrected it @ctrl-alt-delor
â Arushix
May 29 at 3:27
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f446432%2flinux-shell-get-device-id-from-user-input%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password