Sponsored Content
Top Forums UNIX for Dummies Questions & Answers How to get/print the lines from a specified file ? (LINUX) Post 302270832 by rajavu on Tuesday 23rd of December 2008 01:37:32 AM
Old 12-23-2008
How to get/print the lines from a specified file ? (LINUX)

It my first post here .

I just want to get the content of the file as values for printinting along with line number in LINUX

Here is what I tried .

Code:
[orcl10gdb@SVRDELLD37 scheme_opt]$ cat test1.txt
ABC
DSF
GHI
JKL
MNO
PQR
STU
VWX
YZO
[orcl10gdb@SVRDELLD37 scheme_opt]$ cat test.sh
#!/bin/ksh

while read mLine
do
  echo $mLine
done < test1.txt
[orcl10gdb@SVRDELLD37 scheme_opt]$ sh test.sh
: command not found
test.sh: line 6: syntax error near unexpected token `done'
'est.sh: line 6: `done < test1.txt
[orcl10gdb@SVRDELLD37 scheme_opt]$

I am stuck with the error "syntax error near unexpected token `done'"

I am expecting the result as .

Code:
1. ABC
2. DSF
3. GHI
4. JKL
5. MNO
6. PQR
7. STU
8. VWX
9. YZO

Any guide is appreciated.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

print all even lines of a txt file

In other news, I have a colors text file with hundreds of lines, and I want to print only the even numbered lines. for example I have this file looks something like this: ALLCOLORS.TXT red red green red blue red red red green red red blue green green green blue blue blue red blue blue blue... (1 Reply)
Discussion started by: ajp7701
1 Replies

2. Shell Programming and Scripting

Need to print certain lines from a file

Hi ALL, I want to print lines from file using certain conditions for exmple: # The following commands will create a new control file and use it # to open the database. # The contents of online logs will be lost and all backups will # be invalidated. Use this only if online logs are... (25 Replies)
Discussion started by: jack00423
25 Replies

3. UNIX for Advanced & Expert Users

How to print data between 2 lines in a file

i want to print the data between two line numbers in file to another file. which command should i use i tried sed command . i am storing the line numbers in two variables say L1,L2. but $L1 and $L2 are not working in sed command. is there any other command to do this reply soon (5 Replies)
Discussion started by: kamesh83
5 Replies

4. UNIX for Dummies Questions & Answers

find lines from one file in the other and print them

Hi guys, please help me to make a loop! I have two files. File 1 2 4 7 File2 1 abc 2 cde 3 ghgj 4 kjhn 5 mbm 6 hghj 7 hgjk I need to write a script that reads lines from File1, finds them in File2 and puts in File3, so File3 should look like this: (3 Replies)
Discussion started by: coppuca
3 Replies

5. Shell Programming and Scripting

how to print the certain lines in a file to different files

Hi All, File that I have: <ct> <name>group <value>1 <value>2 <value>3 </ct>-->file The output that I needed is <ct> <name>group <value>1 -->file1 <ct> <name>group <value>2 -->file2 (6 Replies)
Discussion started by: natalie23
6 Replies

6. Windows & DOS: Issues & Discussions

Print lines 20-30 from a file

Hi I want to print lines 20-30 from a file. In UNIX , this command will work sed -n '20,30p' file However what is the equivalent command in DOS ? Pls help me ! (2 Replies)
Discussion started by: dashing201
2 Replies

7. Shell Programming and Scripting

print lines AFTER lines cointaining a regexp (or print every first and fourth line)

Hi all, This should be very easy but I can't figure it out... I have a file that looks like this: @SRR057408.1 FW8Y5CK02R652T length=34 AGCAGTGGTATCAACGCAGAGTAAGCAGTGGTAT +SRR057408.1 FW8Y5CK02R652T length=34 FIIHFF6666?=:88@@@BBD:::?@ABBAAA>8 @SRR057408.2 FW8Y5CK02TBMHV length=52... (1 Reply)
Discussion started by: kmkocot
1 Replies

8. Shell Programming and Scripting

Strings from one file which exactly match to the 1st column of other file and then print lines.

Hi, I have two files. 1st file has 1 column (huge file containing ~19200000 lines) and 2nd file has 2 columns (small file containing ~6000 lines). ################################# huge_file.txt a a ab b ################################## small_file.txt a 1.5 b 2.5 ab ... (4 Replies)
Discussion started by: AshwaniSharma09
4 Replies

9. Shell Programming and Scripting

Print matching lines in a file

Hello everyone, I have a little script below: die "Usage infile outfile reGex" if @ARGV != 3; ($regex) = @ARGV; open(F,$ARGV) or die "Can't open"; open(FOUT,"+>$ARGV") or die "Can't open"; while (<F>) { print FOUT if /$regex/.../$regex/; } No matter what I give $regex on the... (2 Replies)
Discussion started by: new bie
2 Replies

10. UNIX for Dummies Questions & Answers

Compare 2 files print the lines of file 2 that contain a string from file 1

Hello I am a new unix user, and I have a work related task to compare 2 files and print all of the lines in file 2 that contain a string from file 1 Note: the fields are in different columns in the files. I suspect the is a good use for awk? Thanks for your time & help File 1 123 232 W343... (6 Replies)
Discussion started by: KevinRidley
6 Replies
All times are GMT -4. The time now is 03:33 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy