Sponsored Content
Top Forums Shell Programming and Scripting Read file and add it into part of file Post 303016074 by rdrtx1 on Thursday 19th of April 2018 08:13:39 AM
Old 04-19-2018
Code:
allow_ports=$(< ports.txt)

while read line
do
   echo "$line" | grep -q "^allow_ports=" && line="allow_ports=\"$allow_ports\""
   echo "$line"
done < main.conf > finall.conf

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

read in part of the file into another file

Hi, I justs started learning Unix on my own. I have a question: What command can I use when I need to read in part of the file into another file? I remember I saw it somewhere but I don't know what it is. Thanks (3 Replies)
Discussion started by: whatisthis
3 Replies

2. Shell Programming and Scripting

Add Date as part of file name

How can I add date in format yyyymmdd to my existing file name ? For example my file name is test.dat then i want it to be test.datyyyymmdd (3 Replies)
Discussion started by: amsh76
3 Replies

3. Shell Programming and Scripting

I'm trying to read from a file and add to LDAP

Hi all I'm trying to write a script that reads from a file and then insert the record by a command line tool into LDAP. here is the file format FirstName LastName uid password and here is the script that I wrot: #!/bin/sh INPUT='/export/home/user/input' while read fname lname uid pass... (0 Replies)
Discussion started by: sh_ksa
0 Replies

4. Shell Programming and Scripting

To Read a File and Insert a part of the lines into the database

Hi Guys I need to have a shell script which reads a log file and insert a part of each line into the database. Some sample lines in the file are as below. 20091112091359 MED_RQACK : user_data=60173054304,100232120,20091112091359,;ask_status=0;ask_reason=OK;msg_id=20091112091319... (5 Replies)
Discussion started by: Somanadh
5 Replies

5. Shell Programming and Scripting

Read file and for each line replace two variables, add strings and save output in another file

Hi All, I have a file, let's call it "info.tmp" that contains data like this .. ABC123456 PCX333445 BCD789833 I need to read "info.tmp" and for each line add strings in a way that the final output is put /logs/ua/dummy.trigger 'AAA00001.FTP.XXX.BLA03A01.xxxxxx(+1)' where XXX... (5 Replies)
Discussion started by: Andy_ARG
5 Replies

6. Shell Programming and Scripting

[Solved] Printing a part of the last line of the specific part of a file

Hi, I have 80 large files, from which I want to get a specific value to run a Bash script. Firstly, I want to get the part of a file which contains this: Name =A xxxxxx yyyyyy zzzzzz aaaaaa bbbbbb Value = 57 This is necessary because in a file there are written more lines which... (6 Replies)
Discussion started by: wenclu
6 Replies

7. Programming

Read file and add value

i have a file outfile.txt which contain 12 22 i have written this program to read the file and show the output,but i dont know how to add these value and show the total. my-codes are #include<cmath> #include<cstdlib> #include<iostream> #include<fstream> using namespace std; int main ()... (4 Replies)
Discussion started by: console
4 Replies

8. Shell Programming and Scripting

Read a file, add some text and send an email

Hi, If I am asking this question, you must have already figured out , that I am new to Unix, so here it goes I was trying to read a file, add some user defined content to it and send out an email , I did find out a way to achieve this, but looking at the code, it looks a bit crude to me, can... (3 Replies)
Discussion started by: karthikbhuvana
3 Replies

9. Shell Programming and Scripting

How to print the specific part of the file name with file creation date?

Hello Folks, I have an requirement, where i need to get total count of the file based on creation date with there filename selected pattern. Filename: MobileProtocol.20171228T154200.157115.udr I want to get the count of files created on each day based on a pattern find. find . -type... (7 Replies)
Discussion started by: sadique.manzar
7 Replies

10. UNIX for Beginners Questions & Answers

How to make a loop to read the input from a file part by part?

Hi All, We've a VDI infrastructure in AWS (AWS workspaces) and we're planning to automate the process of provisioning workspaces. Instead of going to GUI console, and launching workspaces by selecting individual users is little time consuming. Thus, I want to create them in bunches from AWS CLI... (6 Replies)
Discussion started by: arun_adm
6 Replies
ZGREP(1)                                                      General Commands Manual                                                     ZGREP(1)

NAME
zgrep - search possibly compressed files for a regular expression SYNOPSIS
zgrep [ grep_options ] [ -e ] pattern filename... DESCRIPTION
Zgrep invokes grep on compressed or gzipped files. These grep options will cause zgrep to terminate with an error code: (-[drRzZ]|--di*|--exc*|--inc*|--rec*|--nu*). All other options specified are passed directly to grep. If no file is specified, then the standard input is decompressed if necessary and fed to grep. Otherwise the given files are uncompressed if necessary and fed to grep. If the GREP environment variable is set, zgrep uses it as the grep program to be invoked. EXIT CODE
2 - An option that is not supported was specified. AUTHOR
Charles Levert (charles@comm.polymtl.ca) SEE ALSO
grep(1), gzexe(1), gzip(1), zdiff(1), zforce(1), zmore(1), znew(1) ZGREP(1)
All times are GMT -4. The time now is 07:22 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy