append - Concatenate txt file contents and/or add break to all -
append - Concatenate txt file contents and/or add break to all -
i have bunch of.txt files need made 1 big file can read programs such microsoft excel.
the problem files not have break @ end of them, end in 1 long line.
here's illustration of have (the numbers represent line number):
1. | first line of txt file 2. | sec line
here's want turn into:
1. | first line of txt file 2. | sec line 3. |
i have around 3000 of these files in folder, in same format. there way take these files , add together blank line end of them all? i'd without need complicated code, i.e. php, etc.. know there similar things can using terminal (i'm on centos), if require i'm missing it.
the simplest way accomplish bash for-loop:
for file in *.txt; echo >> "$file" done
this iterates on .txt
files in current directory , appends newline each file. can written in 1 line, need add together ;
before done
.
note $file
quoted handle files spaces , other funny characters in names.
if files spread across many directories , not in same one, can replace *.txt
**/*.txt
iterate on .txt
files in subdirectories of current folder.
an alternative way utilize sed
:
sed -i "$ s:$:\n:" *.txt
the -i
flag tells sed
edit files in-place. $
matches lastly line, , s
command substitutes end of line (again $
) new line (\n
), appending line end of file.
append centos concatenation text-files
Comments
Post a Comment