Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.
awk in shell script
Name: schauan Date: April 29, 2004 at 06:33:06 Pacific OS: HPUX 10.20 CPU/Ram: Risc / 128
Comment:
Hello, I want to give back the first 3 letters of my hostname to a variable in a shell script like this principle: N=awk'{printf substr(`uname -n`,1,3) };{exit}' but so it doesn't work. I have one error: The statement `uname -n`cannot be correctly parsed. If I put my hostname in this line my variable havn't any result, and if I take only the awk-command I must press enter to finish it ... Can me help everyone, please? andre
Name: Wolfbone Date: April 29, 2004 at 07:11:42 Pacific
Reply:
N=$(uname -n | cut -c-3)
0
Response Number 2
Name: schauan Date: April 29, 2004 at 11:21:17 Pacific
Reply:
Hello Wolfbone, thanks for your answer, I think, I was a little bit blind today. It's so easy with cut and I thought, cut is only for tables ... And that I can't take every UNIX-command in awk - must pipe it to awk - I know also - sometimes ;-) But can you give me an answer of the second problem - press Enter to finish? p.e. I write awk'{printf substr(myname,1,3) }; {exit}' at the command line, then I press Enter and on screen I have a blank line. Then I press a second time Enter, and now I see the result myn# regards and thanks, schauan
regards everybody, andre
0
Response Number 3
Name: Wolfbone Date: April 29, 2004 at 11:59:52 Pacific
Reply:
Awk was looking for some input - you didn't give it a file so it opened stdin and waited for you to give it something.
Summary: In shell script sed or awk command, can I use hexadecimal code for substitution? I want to perform the following: Input file: Line1 Line2 Line3 Line4 Output file: (all in one line now) Line1Line2Line...
Summary: When running the script below I get nothing.. I am a newbie with this. Not sure If you can run awk in a script. Also Im having problems getting a variable from the command line to the script. from com...
Summary: Hi, I'm trying to run loops in shell scripts using the following script. loop=1 while [ loop -lt 10 ] do echo 'this is my $loop text-line' loop='expr $loop + 1' done ---- but I'm getting error: test: ...