Read file from nth line to specific character


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Read file from nth line to specific character
# 1  
Old 03-22-2012
PHP Read file from nth line to specific character

Hi,

I want to read the file from nth line (where n is an integer) to until I encounter @ char.
Can any one please help me how to do this?

Thanks.
# 2  
Old 03-22-2012
You can do something like that :
Code:
awk 'NR>=From {print; if (/@/) exit }' From=3 inputfile

Jean-Pierre.
# 3  
Old 03-22-2012
Code:
sed -n '3,/@/p' inputfile

# 4  
Old 03-22-2012
for exa from 3.rd line to line with @ and break read..
Code:
# sed -n '3,${;/@/q;p}' infile

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Count specific character of a file in each line and delete this character in a specific position

I will appreciate if you help me here in this script in Solaris Enviroment. Scenario: i have 2 files : 1) /tmp/TRANSACTIONS_DAILY_20180730.txt: 201807300000000004 201807300000000005 201807300000000006 201807300000000007 201807300000000008 2)... (10 Replies)
Discussion started by: teokon90
10 Replies

2. Post Here to Contact Site Administrators and Moderators

How to read the nth character from the line.?

I have Index Line and I tried to get the 9th character from the file and to check the character is "|" or not. Shell Scripting. Sample Index file. "91799489|K8E|188.004.A.917994892.1099R.c.01.pdf|2013|10/15/2014|002|B|C|C"... (3 Replies)
Discussion started by: pavand
3 Replies

3. Shell Programming and Scripting

Insert character at specific location in a each line of the file

Hi All, I am trying to write a shell script where it should insert character 'I' in 180th position of each line(except first and last line) of the file. Below is the script for file in /home/test/bharat/*.RET do # Process file echo "File Name=" $file #l_fileName="${file##*/}" ... (19 Replies)
Discussion started by: bharath561989
19 Replies

4. Shell Programming and Scripting

Removing last character of a specific line from a file

Hello guys, I would need to remove the last character ")" of a specific line. This can be from any line. Your help is appreciated. Below is the line. HOSTNAME=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)) Please help. (6 Replies)
Discussion started by: sang8g
6 Replies

5. Shell Programming and Scripting

Search and recursively enter new line after Nth character

Hi All, My file is a string of around 50K character. I'm trying to insert new line after every 320 character in my file. I know the command to insert newline, but problem is I'm not able to search 320th position. Please advice. (6 Replies)
Discussion started by: Amit786
6 Replies

6. Shell Programming and Scripting

Read a file from the nth line on

I have a script which reads from a job file and executed the scripts in the job file in sequence. #! /bin/ksh set -x while read line do $line.ksh if # mail the team fi done <"$file" The job file will be like abcd efgh ijkl mnop qrst This is working fine. I need to add... (2 Replies)
Discussion started by: nw2unx123
2 Replies

7. Shell Programming and Scripting

How to read one character form each line of the file?

Hi, Maybe this iscorrect forum for my question... I should read one character at a fixed position from each line of the file. So how ??? should be substituted in the code below: while read line ; do single_char=`???` echo "$single_char" done < $input_file OK...I did get an... (0 Replies)
Discussion started by: arsii
0 Replies

8. Shell Programming and Scripting

Print lines with specific character at nth position in a file

I need to print lines with character S at nth position in a file...can someone pl help me with appropriate awk command for this (1 Reply)
Discussion started by: manaswinig
1 Replies

9. Shell Programming and Scripting

Print lines with specific character at nth position in a file

I need to print lines with character S at nth position in a file...can someone pl help me with appropriate awk command for this (2 Replies)
Discussion started by: manaswinig
2 Replies

10. Shell Programming and Scripting

Read First Character of Each Line in File

I need a better way to read the first character of each line in a file and check if it equals the special character ¤. This character tells me where there is a break in the reports. The file has over 500,000 lines. Currently, this is my code - if ] I am using Korn Shell as a scripting... (7 Replies)
Discussion started by: azelinsk
7 Replies
Login or Register to Ask a Question