Sponsored Content
Top Forums Shell Programming and Scripting Cut command issue with shell script Post 302870845 by Aditya_001 on Tuesday 5th of November 2013 03:24:21 AM
Old 11-05-2013
Cut command issue with shell script

I am writing a shell script to skip couple of feilds in a flat file and as a part of this I have written the below piece of code in it.

Code:
 
cut -d '|' -f 1-17,19-31 $1 > filename
 
To add pipe at end of the line I used below command, but it adds even to header and footer as well which i don't need,
 
awk '{print $0"|"}' filename
 
Input File:
492|3076394|SP40|1030028694570|20120125|20120207|13530392|||31||CHAPMAN PLACE|||COLCHESTER|ESSEX|CO4 5ZJ|ADI_001|7|_A|E|A|811|2|0151|EMEB|N|EMEB|N|EMEB|N|1|2|3|4|5|6|7|
 
 
Actual output:
492|3076394|SP40|1030028694570|20120125|20120207|13530392|||31||CHAPMAN PLACE|||COLCHESTER|ESSEX|CO4 5ZJ|7|_A|E|A|811|2|0151|EMEB|N|EMEB|N|EMEB|N
 
 
Expected output file:
 
I need to retain the pipe at last
492|3076394|SP40|1030028694570|20120125|20120207|13530392|||31||CHAPMAN PLACE|||COLCHESTER|ESSEX|CO4 5ZJ|7|_A|E|A|811|2|0151|EMEB|N|EMEB|N|EMEB|N|

I need to know if there is any other way to use the cut command to retain the pipe at end of the line

Awaiting for the suggestions on this,
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Shell script: Cut / (slash) character in string

I have a string "\/scratch\/databases\". I want to have a new string "\/scratch\/databases" by cutting last '\' character using shell script. I can't do this Please help me. Thanks in advance ThuongTranVN (4 Replies)
Discussion started by: ThuongTranVN
4 Replies

2. Shell Programming and Scripting

How to cut, concatenate data in Shell Script

Hello All,, I'm very new to Unix and I'm more in SAP ABAP. I have a requirement for a shell script which will accept one parameter as Input file name(with directory) e.g : /sapdata/deubank/dbdirect/out/deu01deupe/in/deu01deupe20051207111320.pmt In the shell script I have to make two more... (2 Replies)
Discussion started by: vasan_srini
2 Replies

3. Shell Programming and Scripting

Problem using cut command in shell script

I'm new to shell programming, and am having a problem in a (Korn) shell program, which boils down to this: The program reads a record from an input file and then uses a series of "cut" commands to break the record into parts and assign the parts to variables. There are no delimiters in the... (2 Replies)
Discussion started by: joroca
2 Replies

4. Shell Programming and Scripting

cut command issue from a line of text

Hi, I got a line of text which has spaces in between and it is a long stream of characters. I want to extract the text from certain position. Below is the line and I want to take out 3 characters from 86 to 88 character position. In this line space is also a character. However when using cut... (5 Replies)
Discussion started by: asutoshch
5 Replies

5. Shell Programming and Scripting

Cut in shell script

Hi All, Am a Beginner to shell scripting, so please pardon my question. Below is the file format of file a.txt a.txt F=3 a|b|c|d 1|2|3|4 as|as|asd|asd Aas|as|asd|ada In the above file format, i have record count of total no of records excluding the header file here 3 , this varies... (2 Replies)
Discussion started by: sp999
2 Replies

6. Shell Programming and Scripting

korn shell to cut command output

hello, i use following command: md5sum TEST.xml the output looks like: 900hjidur84hjr938ikv TEST.xml as you can see, the first part is the md5 code, the second part is the file name, but i only want the first part(md5 code), and save it to a file, how to do that? thanks. (2 Replies)
Discussion started by: zbc
2 Replies

7. Shell Programming and Scripting

CUT Command and grep issue

I am trying to grep the oracle erros evry day from the logs file. My problem is : -rw-r----- 1 tibcolm tibco 17438361 Apr 5 11:59 RetryService-RetryService.log -rw-r----- 1 tibcolm tibco 245303 Apr 5 12:00 ResponseService-ResponseService.log -rw-r----- 1 tibcolm tibco 2122654 Apr 5 12:00... (4 Replies)
Discussion started by: neeraj617
4 Replies

8. Shell Programming and Scripting

FTP command issue in shell script

Hi All I am using following code in my shell script to send the file to a mainframe server. ftp -in $FTP_IP_SEND <<END_OF_FTP >$LOG_DIR/ProviderExportFTP.log quote user $FTP_USER_SEND quote pass $FTP_PASS_SEND ascii send ./ProviderExport.txt 'PROJ.PDRCACTS.FD87050.EXPORT' (REPLACE... (3 Replies)
Discussion started by: Renjith180282
3 Replies

9. Shell Programming and Scripting

Cut command issue

Need help to append a pipe at end of the line immediately after the cut command, I have an Input flat file with 16 feilds and I am removing the 16th feild by using the cut command as shown, Input: 354|||||CORPORTATION||||NENE PARADE|||WISBECH|CAMBRIDGESHIRE|PE13 3BY|100001| I... (5 Replies)
Discussion started by: Aditya_001
5 Replies

10. Shell Programming and Scripting

Issue with CUT command

Hi All, I am facing an issue while cutting fields with comma delimiter. There are many records with Double quotes in between. My data: aaa,bbb,"ccc, ddd",eee,fff,"ggg ,hhh",iii When i use cut command with comma delimiter, i am getting wrong data like field1=aaa field2=bbb field3="ccc... (3 Replies)
Discussion started by: krishna_gnv
3 Replies
fdetach(1M)															       fdetach(1M)

NAME
fdetach - detach a STREAMS-based file descriptor from a filename SYNOPSIS
path DESCRIPTION
The command detaches or disassociates a file descriptor for an open STREAMS device or pipe from its filename in the file system. The path argument is the path that was previously associated with the file descriptor by the function. Operations on path will subsequently affect the file system node, not the STREAMS device or pipe. The permissions and status of the node are returned to the state that they were in before the STREAMS device or pipe was attached. Any other paths that the STREAMS device or pipe may be attached to are not affected. To successfully issue the command, the user must be superuser or must be the owner of the file and have write permission. RETURN VALUE
returns 0 (zero) on success. If fails, it returns 1 and prints a message to EXAMPLES
To detach the file descriptor for the STREAMS file from its associated file system node, enter: FILES
NLS catalog for SEE ALSO
fattach(3C), fdetach(3C), streamio(7). fdetach(1M)
All times are GMT -4. The time now is 08:44 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy