Simple shot.
File, in file some columns, where one line looks like this (some part from
psql -l -U username)
niet | niet | UTF8
postgres | postgres | UTF8
template0 | postgres | UTF8
template1 | postgres | UTF8
testowa | postgres | UTF8
testowa1 | mzdw | UTF8
testowisko | postgres | UTF8
I need only 1st word from line.
Commands
:1 (move to 1st line)
V (select line)
G (move to end of test and also keep selected)
Then press : (will see this-> :'<,'> )
Type: s/ .*// and press Enter
And all go off ;)
Why ?
Thats why, because 1st character is a space before 'niet, and other dbnames'.
Press u (it will undo changes).
Now, let be a little smart ;) ?????
:1
V
G
:'<,'>s/^ // | '<,'>s/ .*//g
Tap enter and again enter :D
Uff ;)
while read line; do echo $line |awk -F\| '{print $1}'; done <1.txt
OdpowiedzUsuń;)