How to cut, concatenate data in Shell Script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to cut, concatenate data in Shell Script
# 1  
Old 12-07-2005
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 parameters as
a> outfile = /sapdata/deubank/dbdirect/out/deu01deupe/out/deu01deupe20051207111320.pmt
and
b>chkfile = /sapdata/deubank/dbdirect/out/deu01deupe/chk/chkdeu01deupe20051207111320.pmt

I request experts to help me make this file.... Another problem is I don't have any starter help in unix to start with.

Thankx in advance.
Regds.
Srivas.
# 2  
Old 12-07-2005
Here is a script that will do what you require.

But, the logic in it is based on the data you have provided.

Code:
[@~/temp]$ cat vasan.ksh 
#! /bin/ksh
[[ $# -eq 0 ]] && echo " Need an input" && exit 1
FILE="$@"
[[ -f $FILE ]] && echo "$FILE not available" && exit 1

# FILE could look like
# FILE="/sapdata/deubank/dbdirect/out/deu01deupe/in/deu01deupe20051207111320.pmt"

# ROOT_DIR="/sapdata/deubank/dbdirect/out/deu01deupe"
ROOT_DIR=${FILE%/in/*}

# ROOT_OUT="/sapdata/deubank/dbdirect/out/deu01deupe/out"
ROOT_OUT="$ROOT_DIR/out"

# ROOT_chk="/sapdata/deubank/dbdirect/out/deu01deupe/chk"
ROOT_CHK="$ROOT_DIR/chk"

mkdir "$ROOT_OUT"
mkdir "$ROOT_CHK"

cp "$FILE" "$ROOT_OUT"
cp "$FILE" "$ROOT_CHK/chk$FILE"

Not tested.
# 3  
Old 12-07-2005
Thankx Mr. Vino .

Regds.
Srini
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Concatenate 2 files data

Hi, I have one file as: $cat file1 abc pqr 123 def wxy 234 xyz ghi 567 and another file as $cat file2 345 456 987 I want the output of file2 to be appended in file1. And file 1 should look like: $cat file1 abc pqr 123 345 def wxy 234 456 xyz ghi 567 987 (6 Replies)
Discussion started by: Bhrigu
6 Replies

2. UNIX for Advanced & Expert Users

Convert column data to row data using shell script

Hi, I want to convert a 3-column data to 3-row data using shell script. Any suggestion in this regard is highly appreciated. Thanks. (4 Replies)
Discussion started by: sktkpl
4 Replies

3. UNIX for Advanced & Expert Users

Concatenate output in shell script

Hi Colleagues, I need the help in the followind. I execute this. select count(*) from schema.tablew the output is this. select count(*) from schema.table 3955 I need the followind output. select count(*) from schema.table 3955 Thank you for you help. (8 Replies)
Discussion started by: systemoper
8 Replies

4. UNIX for Advanced & Expert Users

Concatenate lines in file shell script

Hi colleagues, I have a file in this format. "/cccc/pppp/dddd/ggg/prueba.txt". ERROR" THE error bbbbbbbbbb finish rows. "/kkkk/mmmm/hhhh/jjj/ejemplo.txt". ERROR This is other error rows.I need my file in this format. "/cccc/pppp/dddd/ggg/prueba.txt". ERROR" THE error bbbbbbbbbb finish rows.... (3 Replies)
Discussion started by: systemoper
3 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

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

7. UNIX for Dummies Questions & Answers

How to cut data block from .txt file in shell scripting

Hi All, Currently i have to write a script. For which i need to cut a block from .txt file. I know the specific word that starts the block and ends the block. Can we do it in shell scripting..? Please suggest.... (6 Replies)
Discussion started by: pank29
6 Replies

8. Solaris

concatenate/sort/cut

I have the following requirement. 1. I have to concatenate the 10 fixed width files. 2. sort based on first 10 characters 3. after that i have remove first 10 chacters from the file. can you please tell me how to do it. Thanks in Advance Samba (1 Reply)
Discussion started by: samba
1 Replies

9. Shell Programming and Scripting

Help with a shell script to concatenate lists together

Below is a description of what im trying to achieve: Write a shell script to concatenate lists together, and output the resulting list. Do not include any argument that is a sub-list of the entire list. (The script will clean the list of any redundant items.) You must preserve the original order... (1 Reply)
Discussion started by: rfourn
1 Replies

10. Shell Programming and Scripting

how to use cut function to obtain this data out in script?

Hi....can you guys help me out in this script?? Below is a text file script....called Bukom.txt and it contains these: BUKOM 20060101 2.5 2.6 2.7 2.8 2.9 2.3 2.1 BUKOM 20060102 2.4 2.5 2.6 2.7 2.7 2.6 2.4 BUKOM 20060103 2.1 2.3 2.5 2.6 2.7 2.7 2.6 Can you guys help... (2 Replies)
Discussion started by: forevercalz
2 Replies
Login or Register to Ask a Question