Cut rowcount from one file to another


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Cut rowcount from one file to another
# 8  
Old 07-10-2009
But you will have some sort of workstation, maybe a windows PC so maybe just open your favourite editor that might have the option to show control characters etc. so that nothing gets lost, mark the 1st 3 rows and copy & paste it in here with CODE-tags as said.
# 9  
Old 07-10-2009
Using posix-shell (ksh, bash, ...)
Code:
# read one line from file = 1st
read first < file
# replace all ; -> space
first=${first//;/ }
echo $first > somefile

If you like to use awk then ex.
Code:
 
cat file | awk -F ";" ' { gsub(/;/," ",$0) ;  print $0;   exit } ' > somefile

# 10  
Old 07-10-2009
Hi kshji!

thanks for the reply Smilie Will check it once, but will this command cut only the first row from a file?

Regards,

PsmakR

---------- Post updated at 02:56 AM ---------- Previous update was at 02:50 AM ----------

Heres the file:


Code:
  COMPANY_CODE;COMPANY_NAME;COMPANY_DESC;CORPORATION_CODE;CORPORATION_NAME;CORPORATION_DESC;SOURCE_SYSTEM;LEGAL_ENTITY
  ZFP;Polpharma S.A.;Polpharma S.A.;ZFP;Polpharma S.A.;Polpharma S.A.;21;BH
  FP;Polpharma S.A.;Polpharma S.A.;ZFP;Polpharma S.A.;Polpharma S.A.;20x;BH
  FP;Polpharma S.A.;Polpharma S.A.;ZFP;Polpharma S.A.;Polpharma S.A.;22x;BH
  FP;Polpharma S.A.;Polpharma S.A.;ZFP;Polpharma S.A.;Polpharma S.A.;;BH

P.S. Command supplied by khji doesnt work ;/ I've got an error code 2.

PsmakR
# 11  
Old 07-10-2009
Can you let us know what output are you expecting from this input and where exactly the character 0d0a is?
# 12  
Old 07-10-2009
Hi!

I'd like to have only this row:

Code:
COMPANY_CODE;COMPANY_NAME;COMPANY_DESC;CORPORATION_CODE;CORPORATION_NAME;CORPORATION_DESC;SOURCE_SYSTEM;LEGAL_ENTITY

without any special characters after it like CHR(13) and CHR(10).

Regards,

Psmakr
# 13  
Old 07-10-2009
You said you have no shell, how do invoke the commands supplied? kshji's lines should work.
Error 2 does not sound like the error code you get from a shell or awk. Maybe you can generate a bit more verbose output than "error 2".
# 14  
Old 07-10-2009
Hi!

As I've said before...Im executing it by a Data Integration tool using its API called OSCommand. It generates an error code 2 nothing more specific ;/

PsmakR
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Using :<<cut / cut to comment out block of bash script

I am using : << cut / cut to comment out block of code. Works fine on few lines of script, then it gives me this cryptic error when I try to comment out about 80 lines. The "warning " is at last line of script. done < results 169 echo "END read all positioning parameters" 170... (8 Replies)
Discussion started by: annacreek
8 Replies

2. Shell Programming and Scripting

How to cut a pipe delimited file and paste it with another file to form a comma separated outputfile

Hello ppl I have a requirement to split (cut in unix) a file (A.txt) which is a pipe delimited file into A1.txt and A2.txt Now I have to join (paste in unix) this A2.txt with external file A3.txt to form output file A4.txt which should be CSV (comma separated file) so that third party can... (25 Replies)
Discussion started by: etldev
25 Replies

3. Shell Programming and Scripting

Help required the cut the whole contents from one file and paste it into new file

Hi, First of all sincere apologies if I have posted in a wrong section ! Please correct me if I am wrong ! I am very new to UNIX scripting. Currently my problem is that I have a code file at the location /home/usr/workarea/GeneratedLogs.log :- Code :- (Feb 7, 571 7:07:29 AM),... (4 Replies)
Discussion started by: acidburn_007
4 Replies

4. Shell Programming and Scripting

cut the variable from the line and use it to find the file and read the content of that file

Hi, I am working on one script..I am having files in the below format file 1 (each line is separated with : delimeter) SPLASH:SPLASH:SVN CIB/MCH:MCH:SVN Now I want from file 1 that most left part of the first line will store in... (6 Replies)
Discussion started by: rohit22hamirpur
6 Replies

5. Shell Programming and Scripting

cut lines from log file and save it another file

Dears, i want cut the lines from a log file. Example of the log file as follows.. May 27, 2011 5:54:51 PM com.huawei.ivas.utilities.sm.client.SMDeliverContrUtil isDeliverSM FINE: May 27, 2011 5:54:51 PM com.huawei.ivas.utilities.sm.client.SMUtil addSysUpMsgLog INFO: . The message content... (1 Reply)
Discussion started by: tonypalokkaran
1 Replies

6. Shell Programming and Scripting

Creating file from an existing file using CUT, is it the best option?

Dear All, I have a requirement in which i have to load a file placed in FTP location onto my database. The process i'll follow is as below: 1) Get the files using FTP. 2) Create the desired load files as i have to load only 19 fields out of the 104 available in the file. The fields i require... (7 Replies)
Discussion started by: abhishekakaomi
7 Replies

7. Shell Programming and Scripting

Cut Command error cut: Bad range

Hi Can anyone what I am doing wrong while using cut command. for f in *.log do logfilename=$f Log "Log file Name: $logfilename" logfile1=`basename $logfilename .log` flength=${#logfile1} Log "file length $flength" from_length=$(($flength - 15)) Log "from... (2 Replies)
Discussion started by: dgmm
2 Replies

8. Shell Programming and Scripting

Compare the rowcount from tables of two databases

All, I have to create a shell script to comapre the rowcount of 120 tables from two oracle databases. In fact, using informatica the data is loading from 120 source tables to 120 staging tables. After that, they want to have a shell script to comapre the rowcount of all these tables. 1) I... (3 Replies)
Discussion started by: Maya_Pillai
3 Replies

9. UNIX for Dummies Questions & Answers

Need to find a rowcount

Hi All, I have a sequential file, with that I want to know row count within. As know we can use, wc -l filename, to find out a row count. But, I found this command works well , if a file is small. It fails to give me rowcount, if File is pretty big. It keeps on processing after we give the... (3 Replies)
Discussion started by: videsh77
3 Replies
Login or Register to Ask a Question