Sponsored Content
Top Forums Shell Programming and Scripting parsing text three fields at a time Post 302361245 by weak_code-fu on Monday 12th of October 2009 06:25:43 PM
Old 10-12-2009
parsing text three fields at a time

I'm programming in csh and I have a text file with hundreds of entries seperated only by spaces. I want to access three fields at a time (as each data set has three components) so that I can send these values to a different routine as three variables until every trio of values in the text file has been processed. The problem is I don't seem to have permission to use the 'read' or 'open' commands on my system (they aren't in my path or I can't copy them into my path because of permissions).

I tried creating an array: set temp = `cat file.txt` but then I can't figure out how to iterate through the array to get three values from it at once without "read" or "open" in a while loop...help? Once again, I'm pretty sure "read" and "open" aren't being recognized as commands.

When I try foreach line ($temp) it only references each individual entry and not a full line.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

combining fields in two text fields

Can someone tell me how to do this using sed, awk, or any other basic shell scripting? Basically I have two text files with the following contained in each file: File A: a b c d e f g h i File B: 1 2 3 I want the final outcome to look like this: a b c 1 d e f 2 g h i 3 How... (3 Replies)
Discussion started by: shocker
3 Replies

2. Shell Programming and Scripting

parsing data file picking out certain fields

I have a file that is large and is broken up by groups of data. I want to take certain fields and display them different to make it easier to read. Given input file below: 2008 fl01 LAC 2589 polk doal xx 2008q1 mx sect 25698541 Sales 08 Dept group lead1 ... (8 Replies)
Discussion started by: timj123
8 Replies

3. Shell Programming and Scripting

How to read and compare multiple fields in a column at the same time

Hi, Currently I am coding up a nasty way of reading file input using *cat* rather than *read*. My text input looks like TextA 100 TextB 110 TextC 120 Currently I am using cat |while read line to read the first column and second column fields. cat foo.txt|while read line do ... (1 Reply)
Discussion started by: ahjiefreak
1 Replies

4. Shell Programming and Scripting

Parsing text

Hello all, I have some text formatted as follows Name: John doe Company: Address 1: 7 times the headache Address 2: City: my city State/Province: confusion Zip/Postalcode: 12345 and I'm trying to figure out how I could extract the data after the colon so that the result would be ... (6 Replies)
Discussion started by: mcgrailm
6 Replies

5. Shell Programming and Scripting

Parsing iostat in real time

I'm trying to write a script that will parse the output of the iostat command in real time and place the output in csv file(s). I do have a programming background, but am relatively new to shell so I'm having difficulties determining how to proceed. The cpu stats will go into one output... (6 Replies)
Discussion started by: fastergrace
6 Replies

6. Shell Programming and Scripting

Help with text/number parsing

Hello I have a file that contains 10 rows as below: "ID" "DP" "ID=GRMZM2G015073_T01" "23.6044288292005" "ID=GRMZM2G119852_T01" "59.7782287606723" "ID=GRMZM2G100242_T02" "61.4167813736184" "ID=GRMZM2G046274_T01" "6.63061838134219" "ID=GRMZM2G046274_T02" ... (5 Replies)
Discussion started by: cs_novice
5 Replies

7. Shell Programming and Scripting

Parsing fields from class list files to use output with newusers command

Hello I am trying to develop a shell script that takes a text file such as this... E-mail@ Soc.Sec.No. *--------Name-----------* Class *School.Curriculum.Major.* Campus.Phone JCC2380 XXX-XX-XXXX CAREY, JULIE C JR-II BISS CPSC BS INFO TECH 412/779-9445 JAC1936 XXX-XX-XXXX... (7 Replies)
Discussion started by: crimputt
7 Replies

8. Shell Programming and Scripting

Text parsing

Hi All! Is it possible to convert text file: to: ? (6 Replies)
Discussion started by: y77
6 Replies

9. Shell Programming and Scripting

Parsing fields into variables

A record contains 50 fields separated by "~". I need to assign each of these fields to different variables. Following is the shell script approach I tried. RECORD="FIELD1~FIELD2~FIELD3~FIELD4~FIELD5~...........~FIELD50" VAR1=$(echo ${RECORD} | cut -d"~" -f 1) VAR2=$(echo ${RECORD} | cut... (5 Replies)
Discussion started by: krishmaths
5 Replies

10. UNIX for Beginners Questions & Answers

Getting the current time from a website and parsing date

I am trying to work on a script to grab the UTC time from a website So far I was able to cobble this together. curl -s --head web-url | grep ^Date: | sed 's/Date: //g' Which gives me the result I need. Wed, 06 Dec 2017 21:43:50 GMT What I need to is extract the 21:43:50 and convert... (4 Replies)
Discussion started by: allisterB
4 Replies
access(2)							System Calls Manual							 access(2)

NAME
access() - determine accessibility of a file SYNOPSIS
DESCRIPTION
The system call checks the file pointed to by path for accessibility according to the bit pattern contained in amode. uses the real user ID, not the effective user ID, and the real group ID, not the effective group ID. The value of amode is either the bit-wise inclusive OR of the access permissions to be checked, or the existence test. You can use the following symbolic constants, defined in to test for permissions: Read access Write access Execute (search) access Check existence of file The owner of a file has permission checked with respect to the "user" read, write, and execute mode bits. Members of the file's group other than the owner have permissions checked with respect to the "group" mode bits. All others have permissions checked with respect to the "other" mode bits. If a file is currently open for execution, reports that it is not writable, regardless of the setting of its mode. Access Control Lists - HFS File Systems Only Read, write, and execute/search permissions are checked against the file's access control list (ACL). Each mode is checked separately since different ACL entries can grant different permissions. The real user ID is combined with the process's real group ID and each group in its supplementary groups list, and the access control list is searched for a match. Search proceeds in order of specificity and ends when one or more matching entries are found at a specific level. More than one or entry can match a user if that user has a nonnull sup- plementary groups list. If any matching entry has the appropriate permission bit set, access is permitted. Access Control Lists - JFS File Systems Only Read, write, and execute/search permissions are checked against the file's access control list (ACL). The real user ID is combined with the process's real group ID and each group in its supplementary groups list, and the access control list is searched for a match. Search proceeds in order of ACL entries and ends when the first entry matching the user ID or any of the group IDs is encountered. If a shared text file is currently open for execution, reports that it is not writable, regardless of its access control list. However, does not report that a shared text file open for writing is not executable, since the check is not easily done. It also reports that a file on a read-only file system is not writable. Security Restrictions If the path is valid and the real user ID is superuser or a user with and privileges, always returns except when amode includes the path is not a directory, and none of the execute bits are set in the file's mode. See privileges(5) for more information about privileged access on systems that support fine-grained privileges. RETURN VALUE
returns the following values: Successful completion. The requested access is permitted. Failure. is set to indicate the error. ERRORS
If fails, is set to one of the following values. Search permission is denied on a component of the path prefix. The access control list does not permit the requested access and the real user ID is not a user with or privileges. path points outside the allocated address space for the process. The reliable detection of this error is implementation dependent. Too many symbolic links were encountered in translating the path name. The length of the specified path name exceeds bytes, or the length of a component of the path name exceeds bytes while is in effect. Read, write, or execute (search) permission is requested for a null path name. The named file does not exist. A component of the path prefix is not a directory. Write access is requested for a file on a read-only file system. Write access is requested for a pure procedure (shared text) file that is being executed. SEE ALSO
acl(2), chmod(2), stat(2), setacl(2), acl(5), aclv(5), privileges(5), unistd(5). STANDARDS CONFORMANCE
access(2)
All times are GMT -4. The time now is 04:42 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy