Link to home
Start Free TrialLog in
Avatar of mbpssgms
mbpssgms

asked on

printig 20 lines from string

hi  I need to write an awk script that prints 20 lines from a string and directs output to a file.
pls help.
Avatar of mikelfritz
mikelfritz
Flag of United States of America image

Can you give an example of the input and desired output?
Avatar of Tintin
Tintin

How does your string store 20 lines?
strings in shell scripts do not have \n or \r or anything like that in tham as far as I know.

If you have managed to get new lines into a string then you could echo it and then pipe it to head and then pipe that into a file

echo "$string" | head -n 20 > /path/file.txt

The question needs clarification.  At this point all we could do is guess at the i/o.
ASKER CERTIFIED SOLUTION
Avatar of ahoffmann
ahoffmann
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mbpssgms

ASKER

thanks I'd been away.  This was similar to another solution.