Read file line by line in unix script




















Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Learn more. Unix script to read the file and create a file for each line Ask Question. Asked 3 years, 3 months ago. Active 3 years, 3 months ago. Viewed times. Example The file has these two lines: My name is hello world My Name is not hello world What I want is the following: File 1 should have 1 record and name of this file is fourth field of row which What do you mean exactly?

First file should be named: hello File 2 should have 2nd record and name of the file should be 4 field of row which is not. Here also. What do you mean exactly? Second file should be named: not. Improve this question. Rui F Ribeiro Animesh Saxena Animesh Saxena 9 1 1 bronze badge.

Please review the Help Center to get information on how to best post on this site. To get to your question, what have you tried so far? You mention that you are using a UNIX system, could you include what shell or operating system you are using to help others know what tools you have available? Please edit your post to include this information. The more context you can add the better others will be able to help you! Hello Animesh Saxena would you please check the answer below and let me know if this is what you need?

Please re-edit the question for further clarifications and include the expected output. Animesh, Is this what you want? AnimeshSaxena It will create 2 files. Once again main is your filename containing those 2 lines — Valentin Bajrami. Shell Programming and Scripting. How to read a file, line by line in UNIX script?

Registered User. Join Date: May Code :. Last edited by bartus11; at PM.. Reason: Please use code tags. Join Date: Jan It is definitely reading that file, but you cannot reference a shell variable inside an awk code by using dollar sign. So below statement in awk code is wrong: Code :. Find all posts by Yoda. Input are file and file1 file contains store. Last edited by Franklin52; at AM.. Shell script UNIX to read text file line by line.

With script bash, read file line per line starting at the end. Hello, I'm works on Ubuntu server My goal : I would like to read file line per line, but i want to started at the end of file. The file is long Create a free Team What is Teams?

Collectives on Stack Overflow. Learn more. Asked 8 years, 7 months ago. Active 1 year, 6 months ago. Viewed k times. Please suggest a way. Improve this question. Preeti Maurya 1 1 gold badge 5 5 silver badges 17 17 bronze badges. Sourabh Saxena Sourabh Saxena 1 1 gold badge 2 2 silver badges 5 5 bronze badges.

Add a comment. Active Oldest Votes. Improve this answer.



0コメント

  • 1000 / 1000