I want to split a file into multiple ones, with a new file for every line in the old file. Typically it is in this format
I can make new files by using split or other simple awk commands. But sometimes, the file is like this
or
Even in these cases I want place holder files to be created. So even for just one row, I want four files, where three will be empty.
The script needs to know, how many empty files it should create. That can be my some kind of maximum value or by empty lines in the original file (if there are any).
Here an example with manually giving 5 as maximum number of files:
Hi,
Thanks so much for the response, to make things simpler, my base file will have one of these 4 values in the first column- .25 .5 .85 and 1.3. So if any of these exist in the file, then write just that line to a new file. whenever a column entry does not exist, then just write the value (one of those 4) and leave the 2nd column blank.
---------- Post updated at 11:16 AM ---------- Previous update was at 11:15 AM ----------
@vbe I can have a maximum of 4 lines, if there are only 2, even that case i want to create 4 files with place holders in 2.
That is because awk has some limitations w.r.t. to the number of files open at a particular time. But, that is implementation (and sometimes, system) specific.
In ksh93, I could write that code snippet as:
If you are using bash, you could turn extglob on (shopt -s extglob) before running this.
This User Gave Thanks to elixir_sinari For This Post:
OK So I Recently Bought A whatbox Seed-box Act!!:cool:
I am connected to whatbox via SSH!!!
Now i have downloaded a movie and renamed it to 2yify.mp4 (800MB):o
When I TYPE the command to split it which is:)
split -b 400m 2yify.mp4
It gets renamed into two parts with different names... (4 Replies)
Hi All,
My requisite is to split a single column of phonemes seperated by spaces into multiple rows.
my input file is:
a
dh
u
th
a
qn
ch
A
v
U
r
k
my o/p should be like:
adhu a dh u (3 Replies)
Dear experts,
I have a problem and I am not clear on how to attack this. Let me define the problem as simply as possible.
1)There are several log files in a directory
2) Script should open each log file and scan for errors (grep for certain strings - say - error1, error2, error3)
3) If any... (1 Reply)
Hi, I have 2 files which represent data in a Sybase table and I need to run a diff on them, and based on the first column (which is the primary key) in each file, create 3 files, one for inserts, one for deletes and one for updates
Example:
old.txt contains
server1,a,b,c
server2,d,e,f... (4 Replies)
Hi all
I have two files which are essentially the same. However the way an exponent is written is different (i.e. in 1 file, a particular number might be written as 1.43230000E+02 whereas in another it might be 1.4323E2).
If I use SDIFF then the program will merely check the ASCII characters... (1 Reply)
Hi all,
I'm writing an uninstaller for a bespoke piece of software that we deploy to our Linux terminals.
One of the packages we install is the JDK (Java Development Kit). Now over the years we have quite a number of different versions installed with different package names. In my uninstaller... (0 Replies)