Remove all lines except lines starting with [


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Remove all lines except lines starting with [
# 1  
Old 03-03-2011
Remove all lines except lines starting with [

Hello,

I am trying to remove all the lines in file except lines starting with [

How can i accomplish this?

Thank you very much in advance.
# 2  
Old 03-03-2011
Code:
# grep \\[ file1

# fgrep [ file1

# To update the file if using GNU sed:
# sed -in "/^\[/p" file1

# 3  
Old 03-03-2011
Worked like a charm. Thanks a lot.
# 4  
Old 03-03-2011
I have one requirement. I am reading the value from .csv file. below is the sample
dir_str,test,directory structure
scp_path," /abc/test/a1.sh
/abc/test/a2.sh
/abc/test/a3.sh",path where script files are present
other_files,"/abc/other/o1.txt
/abc/other/o2.txt",path where other files are present

in this csv file i have 3 columns. the value in the second column is provided by the user. I want to extract the details with in the " " after the scp_path word.

how this can be done using sed or awk command?

Can anyone please help?

I
# 5  
Old 03-03-2011
I have one requirement. I am reading the value from .csv file. below is the sample
dir_str,test,directory structure
scp_path," /abc/test/a1.sh
/abc/test/a2.sh
/abc/test/a3.sh",path where script files are present
other_files,"/abc/other/o1.txt
/abc/other/o2.txt",path where other files are present

in this csv file i have 3 columns. the value in the second column is provided by the user. I want to extract the details with in the " " after the scp_path word.

how this can be done using sed or awk command?

Can anyone please help?

I AM
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Need to remove lines starting with an ID from all fine in a director

Hi All, I have almost 200 files in a directory I want to remove all lines in each file that is starting with 88002 and 88003. I tried with grep -v and if I plan to do that I need to for all the files individually and it is 200+ files. Any way I can do at single command ... (4 Replies)
Discussion started by: arunkumar_mca
4 Replies

2. Shell Programming and Scripting

awk to remove lines that do not start with digit and combine line or lines

I have been searching and trying to come up with an awk that will perform the following on a converted text file (original is a pdf). 1. Since the first two lines are (begin with) text they are removed 2. if $1 is a number then all text is merged (combined) into one line until the next... (3 Replies)
Discussion started by: cmccabe
3 Replies

3. UNIX for Dummies Questions & Answers

How to grep a line not starting with # from a file (there are two lines starting with # and normal)?

e.g. File name: File.txt cat File.txt Result: #INBOUND_QUEUE=FAQ1 INBOUND_QUEUE=FAQ2 I want to get the value for one which is not commented out. Thanks, (3 Replies)
Discussion started by: Tanu
3 Replies

4. Shell Programming and Scripting

Remove lines that are subsets of other lines in File

Hello everyone, Although it seems easy, I've been stuck with this problem for a moment now and I can't figure out a way to get it done. My problem is the following: I have a file where each line is a sequence of IP addresses, example : 10.0.0.1 10.0.0.2 10.0.0.5 10.0.0.1 10.0.0.2... (5 Replies)
Discussion started by: MisterJellyBean
5 Replies

5. UNIX for Dummies Questions & Answers

Want to remove all lines but not latest 50 lines from a file

Hi, I have a huge file which has Lacs of lines. File system got full. I want your guys help to suggest me a solution so that I can remove all lines from that file but not last 50,000 lines. I want solution which can remove lines from existing file so that I can have some space left with. (28 Replies)
Discussion started by: prashant2507198
28 Replies

6. Shell Programming and Scripting

remove blank lines and merge lines in shell

Hi, I'm not a expert in shell programming, so i've come here to take help from u gurus. I'm trying to tailor a csv file that i got to make it work for the LOAD FROM command. I've a datatable csv of the below format - --in file format xx,xx,xx ,xx , , , , ,,xx, xxxx,, ,, xxx,... (11 Replies)
Discussion started by: dvah
11 Replies

7. Shell Programming and Scripting

Concatenate lines between lines starting with a specific pattern

Hi, I have a file such as: --- >contig00001 length=35524 numreads=2944 gACGCCGCGCGCCGCGGCCAGGGCTGGCCCA CAGGCCGCGCGGCGTCGGCTGGCTGAG >contig00002 length=4242 numreads=43423 ATGCCGAAGGTCCGCCTGGGGCTGG CGCCGGGAGCATGTAGCG --- I would like to concatenate the lines not starting with ">"... (9 Replies)
Discussion started by: s052866
9 Replies

8. Shell Programming and Scripting

remove lines starting with

Hi I have an input file... /* ----------------- AGYDLY_Box ----------------- */ insert_job: AGYDLY_Box job_type: b owner: spdrdev permission: gx,wx date_conditions: 1 days_of_week: mo,tu,we,th,fr exclude_calendar: mtg_holidays start_times: "1:00" description: "Process Daily New pools... (2 Replies)
Discussion started by: ramky79
2 Replies

9. Shell Programming and Scripting

shell script to remove all lines from a file before a line starting with pattern

hi,, i hav a file with many lines.i need to remove all lines before a line begginning with a specific pattern from the file because these lines are not required. Can u help me out with either a perl script or shell script example:- if file initially contains lines: a b c d .1.2 d e f... (2 Replies)
Discussion started by: raksha.s
2 Replies

10. UNIX for Dummies Questions & Answers

remove lines in text starting with . (period)

how can i remove lines from a text file starting with . (a period) (11 Replies)
Discussion started by: Movomito
11 Replies
Login or Register to Ask a Question