Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Click here to start participating now! Also, check out the New User Guide.
Unix Korn shell script to read recs
Name: Scott H Date: January 21, 2003 at 07:51:51 Pacific OS: AIX CPU/Ram: ?
Comment:
I need to be able to grab the first character in record1 of a file and see if it is the number "1". I then need to grab the first character in record2 of the same file and see if it is the number "9". I can write simple scripts, but this is a new one for me. Is AWK the way to go? (I am also new to AWK) Any help with this would be greatly appreciated. An example of what a portion of the file could look like is shown below.
Name: Scott H Date: January 21, 2003 at 09:45:21 Pacific
Reply:
One thing that I forgot to add is that I only care about the first character in the first two lines/records. I don't need to read the rest of the file if there happens to be more than 2 lines/records in it.
Thanks, Scott
0
Response Number 2
Name: LANkrypt0 Date: January 21, 2003 at 12:38:41 Pacific
Reply:
So, if I am reading this right, you only need the first character of the first 2 lines correct?
If so head -2 FILENAME | cut -c 1
Would give you 1 9
If you need to separate them, use either: | head -1 or | tail -1 at the end
That should work just fine.
0
Response Number 3
Name: Scott H Date: January 21, 2003 at 13:27:11 Pacific
Reply:
Thanks LANkrypt0. I feel silly now to see how simple that was.
By the way, it worked great!
Scott
0
Response Number 4
Name: LANkrypt0 Date: January 22, 2003 at 05:13:28 Pacific
Reply:
No problem.
I too have overcomplicated things many times, only to realize later on that some little line of code would have produced the same thing. You learn as you go.
Summary: Hello, I need to create a korn shell script that will read columns from a seperate file. For instance: filename: inventory color size type red large shirt blue med hat green small t...
Summary: Hi, I am trying to read a file which has two fields i.e tab seperated. Each line has an OldImage Name and a NewImage Name. Can anyone help me to write a shell script which reads the file and changes t...
Summary: hello, I am having trouble creating a batch script to FTP a file from UNIX to NT. It seems that when I invoke the script, the ftp command invokes the interactive ftp interpreter and does not return c...