How can i add each line from a txt file to different files in the same directory?
Hello, this is my first thread here
So i have a text file that contains words in each line like
and i have 4 txt files, i want to add each line to each file, like file 1 gets abcd at the end; file 2 gets efgh at the end ....
I tried with:
but each time the whole txt is written to each file, i just want each line to each file, not the whole text.
Thanks in advance
Moderator's Comments:
Please use CODE tags as required by forum rules!
Last edited by RudiC; 04-11-2019 at 05:07 PM..
Reason: Added CODE tags.
The behaviour you describe is easily understood: you read a line, then echo it to all files in the directory except "test", then read the next line, append to all again, and so forth.
Your request is not quite complete. Does it matter which line goes to which file? What if there's more lines than files / more files than lines?
no it doesn't matter what line goes what file.
for example test has in it:
I have 4 files as well in the same directory.
All i want is: abcd goes to the end of file 1 efgh goes to the end of file 2 ijkl goes to the end of file 3 mnop goes to the end of file 4
Thanks
Moderator's Comments:
Please use CODE tags as required by forum rules!
Last edited by RudiC; 04-11-2019 at 05:53 PM..
Reason: Added CODE tags.
If your shell offers "extended pattern matching" with the extglob shell option, you could avoid the if construct in your loop:
will list all files in your current working directory except test.
I need a hint for reading manpage (I did rtfm really) of cpio to do this task as in the headline described. I want to put all files of a certain type, lets say all *.txt files or any other format. Spread in more than hundreds of subdirectories in one directory I would like to select them and just... (3 Replies)
Hi All
Is there a way to export every line into new txt file where by the title of each txt output are same as the line ?
I have this txt files containing names:
Kandra Vanhooser
Rhona Menefee
Reynaldo Hutt
Houston Rafferty
Charmaine Lord
Albertine Poucher
Juana Maes
Mitch Lobel... (2 Replies)
wget -x -i link.txt
The above downloads and create unique entries for the 97 links in the text file. However, each new file is saved as CM080 with a FILE extention. Is there a way to convert each file in that directory to a .txt? The 97 files are in... (12 Replies)
Friends,
I am in need to delete files from a directory on a regular basis. I want to place all the files to be deleted in delete .txt file and require a script to delete files, line by line from this delete.txt file. Please help me with this script as am new to unix scripting. (3 Replies)
I want to add/append the info in the following format to my.txt file.
20130702|abcd20130702.txt FN|SN|DOB
I tried the below script but it throws me some exceptions.
<#!/bin/sh
dt = date '+%y%m%d'members;
echo $dt+|+members+$dt;
/usr/bin/awk -f
BEGIN { FS="|"; OFS="|"; } { print... (6 Replies)
Hi Guys,
I have file A.txt
File A Data
AK1521
AK2536
AK3164
I want create text file of all data above and write some data on each file.
want Output on below folder
/home/kka/out
AK1521.txt
Hi
Welocme (3 Replies)
HI All,
I am coding a shell script which will pick all the .csv files in a particular directoryand write it in to a .txt file, this .txt file i will use as a source in datastage for processing.
now after the processing is done I have to move and archive all the files in the .txt file to a... (5 Replies)
I have many types of files (Eg: *.log, *.rpt, *.txt, *.dat) in a directory. I want to display all file types except *.txt.
What is the command to display all files except "*.txt" (9 Replies)