Monday, 19 August 2013

How to get line 1 from file : aaa, and then line 2, from file aaa. seperately, usuable within a bash script, anywhere.

How to get line 1 from file : aaa, and then line 2, from file aaa.
seperately, usuable within a bash script, anywhere.

I have a bash script that is something like this..
a=`xdotool search --name "ooo"`
if [[ "$a" ]]; then
xdotool windowactivate --sync $a
fi
above this code i need to mention
b = 'username'
c = 'password'
but i rather store the username and password in a text file named
a
in other words i need to do something like..
b = read_the_first_line_from_file_a
c = read_the_second_line_from_file_a
so far i came across with these codes. but they do not look "fit" for my
needs.
awk '{a[NR]=$0}END{ #here you could do whatever with a[1] (a) and a[2] (b)}
you see this code above i have been given.. how am i suppose to integrate
it with
b =
c =
?
is there a generic way to simply get line1 and line2 from a file and
assign them to variables in linux ?

No comments:

Post a Comment