Sponsored Content
Full Discussion: multiple cuts syntax problem
Top Forums UNIX for Dummies Questions & Answers multiple cuts syntax problem Post 84504 by Gerry405 on Monday 26th of September 2005 07:57:09 AM
Old 09-26-2005
cutting and sorting

Hi sorry about that,

sample below of file....

cat WAITING | wc -l
11924

head -5 WAITING | pg
Code:
IG405HC7  1342567SG002534181190725G52 1HP G52202     ADCR                           26090511310797       C292 011198
IG405HCB  4558796SG003527361070252G52 3AW G52378      LA CHECK CYSTOSCOPY           26090572040301       M459
IG405HCB  0724968SG002842631200638PA4 8QN C87700      CHECK CYSTOSCOPY              26090572160198       M459
IG405HCB  0019635SG009338692051223G46 7QN G49200      CHECK CYSTOSCOPY              26090512300797       M459
IG405HCB  0019635SG009383181240814G74 2AN L63315      LA CHECK CYSTOSCOPY           26090572190897       M459

actual script is below....

Code:
#! /bin/sh
echo " "
#echo "                         " $STRING;
cut -c1 WAITING > col1          # type
cut -c2-6 WAITING > col2        # location code
cut -c7-10 WAITING > col3       # spec code
cut -c11-17 WAITING > col4      # consultant
cut -c18-27 WAITING > col5      # crn
cut -c28 WAITING > col6        # Male/Female/Unknown
sed -e s/1/Male/ -e s/2/Female/ -e s/0/Unknown/ col6 > col6a
cut -c29-34 WAITING > col7        # date of birth
cut -c35-42 WAITING > col8        # Post code
awk '{print NF ? $0 : blankrow}' blankrow="blank_Pcode" col8 > Col8a
mv Col8a col8
cut -c43 WAITING > col9           # Healthboard
awk '{print NF ? $0 : blankrow}' blankrow="blank_Health" col9 > col9b
mv col9b col9
cut -c44-48 WAITING > col10       # practice code
cut -c54 WAITING > col12        # unknown
cut -c55-84 WAITING > col13     # free text
cut -c85-90 WAITING > col14     # date
cut -c91 WAITING > col15        # single
sed -e s/1/Inpatient/ -e s/7/Daycase/ col15 > col15a
cp col15a col15
cp col15 /u1/excel/Dups
cut -c92 WAITING > col16        # True or Repeat
sed -e s/1/True/ -e s/2/Repeat/ col16 > col16a
cp col16a col16
cut -c93-98 WAITING > col17     # blank_spaces
cut -c99-104 WAITING > col18    # Date
cut -c105 WAITING  > col19    # Canceled
cut -c106-109 WAITING > col20   # ????
cut -c111-116 WAITING > col21   # Date
cp col12 col12a
sed -e s/0/"No ASC"/ -e s/2/ASC/ -e s/4/ASC/ -e s/8/ASC/ -e s/A/ASC/ -e s/ASCSC/ASC/ col12a > col12bb
awk '{print NF ? $0 : blankrow}' blankrow="No ASC" col12bb  > col12a
paste col[1-3] col3a col4 col4a col5 col6a col[7-9] col9a > test1
paste col1[0-1] col12a col12 col1[3-9]> test2
paste col2[0-1] T_formula > test3
paste test*  > joined
cat ELLA | grep "blank_" > /u1/excel/errors.txt
cp joined /u1/excel/Dups
cat T_heading joined > ELLA
echo "\n\n\n\t\t\t ......F I N I S H E D >>>contents in file named (ELLA) "
sleep 3
rm test[1-3] joined col[1-5] col[7-9] col1[0-9]* col2[0-1]


Last edited by vgersh99; 09-26-2005 at 02:44 PM..
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

syntax problem

dear friends, I have a large size file containg two fields data like this *** **** 122 222 ***** ***** ***** ***** 232 233 i have file like this. i want to remove blank lines from file . i think awk is servive this problem i wrote a awk command but the error is... (3 Replies)
Discussion started by: rajan_ka1
3 Replies

2. Shell Programming and Scripting

syntax problem

Dear friends, I am writing shell script in csh . i want to make arthimatic operation in csh. i wrote sysntax like this. set val = 230 set tmp = `0.1 * $val + 300` echo $tmp but it is not working . anyone please give me syntax. (3 Replies)
Discussion started by: rajan_ka1
3 Replies

3. Solaris

Custom short cuts not working on JDS

Hello, I had created a shortcut to open up a gnome-terminal by pressing <Alt>m. This worked fine, until I logged out and logged back in. gnome-terminal no longer opens. However, the process is created, as evidenced by the gnome-terminal showing up on my process list. I've created and deleted... (1 Reply)
Discussion started by: cooldude
1 Replies

4. Shell Programming and Scripting

How do I write multiple variable syntax?

I am trying to write a script that will do a sql statement. But in the sql I will have a list (1,2,3,4). How would I go about asking for the input from the user running the script, and then transferring that back into the list as say ($var1,$var2,$var3)? It would be somewhat like this: ... (1 Reply)
Discussion started by: Captain
1 Replies

5. Shell Programming and Scripting

Multiple echos and cuts too slow

Hi guys, hopefully this hasn't been asked before - couldn't see the question anywhere. I have a large number of timestamps (hh-mm-ss-millisecond) that I need to find the difference between e.g.: 14-11-07-513 14-11-07-644 Now the script that I have just knocked up is horrifically slow,... (4 Replies)
Discussion started by: dlam
4 Replies

6. Shell Programming and Scripting

Awk if-else syntax with multiple columns

I can't seem to get this to work. I can reformat the date field if it's the first field (and only field) in the file: However, I get a syntax error when the date field is the second field (or has any other columns following): I can use a ";" but then it puts each column on separate... (8 Replies)
Discussion started by: giannicello
8 Replies

7. Shell Programming and Scripting

Problem with if-else syntax

I'm calling the following if-else from nawk. But I keep getting an error at the "else". I've tried putting more brackets and ; but still I get complaints about the "else". Any ideas ? Thanks, wbrunc BEGIN { FS = "," ; OFS = "," } { if ( $8 ~ /A/ && $9 == B ) $1="4/29/2013" ; $2="J.Doe"... (2 Replies)
Discussion started by: wbrunc
2 Replies

8. Shell Programming and Scripting

Python script cuts off early

I wasn't sure if this should go in the networking board or not, since I am trying to log into routers, however I don't think my script issues have anything to do with the routers themselves.... I am trying to write a script that will log into various routers we have on the network and determine... (2 Replies)
Discussion started by: ippy98
2 Replies

9. AIX

Multiple DNS forwarders and syntax question.

Hey Guy's, Is there a limit on the number of forwards that can be used or the syntax and spaces? I noticed I have to put spaces between ; and the IP for at least the first one, then space at the end to work and the rest don't work at all no matter what I try. forward first; ... (1 Reply)
Discussion started by: Devyn
1 Replies
cut(1)							      General Commands Manual							    cut(1)

Name
       cut - cut out selected fields of each line of a file

Syntax
       cut -clist [file1 file2...]
       cut -flist [-dchar] [-s] [file1 file2...]

Description
       Use  the  command to cut out columns from a table or fields from each line of a file.  The fields as specified by list can be fixed length,
       that is, character positions as on a punched card (-c option), or the length can vary from line to line and be marked with a  field  delim-
       iter character like tab (-f option).  The command can be used as a filter.  If no files are given, the standard input is used.

       Use to make horizontal ``cuts'' (by context) through a file, or to put files together in columns.  To reorder columns in a table, use and

Options
       list	   Specifies  ranges  that must be a comma-separated list of integer field numbers in increasing order.  With optional - indicates
		   ranges as in the -o option of nroff/troff for page ranges; for example, 1,4,7; 1-3,8; -5,10 (short for 1-5,10);  or	3-  (short
		   for third through last field).

       -clist	   Specifies character positions to be cut out.  For example, -c1-72 would pass the first 72 characters of each line.

       -flist	   Specifies  the  fields  to be cut out.  For example, -f1,7 copies the first and seventh field only.	Lines with no field delim-
		   iters are passed through intact (useful for table subheadings), unless -s is specified.

       -dchar	   Uses the specified character as the field delimiter.  Default is tab.  Space or other characters with special  meaning  to  the
		   shell must be quoted.  The -d option is used only in combination with the -f option, according to XPG3 and SVID2/SVID3.

       -s	   Suppresses  lines  with  no	delimiter  characters.	 Unless  specified, lines with no delimiters are passed through untouched.
		   Either the -c or -f option must be specified.

Examples
       Mapping of user IDs to names:
       cut -d: -f1,5 /etc/passwd
       To set name to the current login name for the csh shell:
       set name=`who am i | cut -f1 -d" "`
       To set name to the current login name for the sh, sh5, and ksh shells:
       name=`who am i | cut -f1 -d" "`

Diagnostics
       "line too long"	   A line can have no more than 511 characters or fields.

       "bad list for c/f option"
			   Missing -c or -f option or incorrectly specified list.  No error occurs if a line has fewer fields than the list  calls
			   for.

       "no fields"	   The list is empty.

See Also
       grep(1), paste(1)

																	    cut(1)
All times are GMT -4. The time now is 05:56 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy