Another question that I have is how to manipulate text files.
I joined several files to one big. Now I have all headlines of the files in the new big one and want to delete them in the file without saving under a new one.
My file is separated by ";" and used to stay separated by ";"
I searched and found a oneliner here: How to find lines matching a pattern and delete them?
I tried it in my cmd (I'm running windows) and get the error message:
gawk: fatal: can't open source file `inplace' for reading (No such file or directory)
My codeline is:
gawk -i inplace "!/^Address (CO)/" filename.txt
I don't find anything about how to alternate it to Windows, if there is something special except for changing ' to "". All the headline contain the work "Address (CO)" in first column.
Sample of my Input:
Address (CO) - Costumer - Phone_Number
Mainstreet 1 - Carl Monte - 123456
Mainstreet 2 - Anja Coleman - 407846
Address (CO) - Costumer - Phone_Number
Mainstreet 10 - Sebastian Wol - 756189
Mainstreet 7 - Dennis Mann - 694311
Address (CO) - Costumer - Phone_Number
...
Desired Output:
Address (CO) - Costumer - Phone_Number
Mainstreet 1 - Carl Monte - 123456
Mainstreet 2 - Anja Coleman - 407846
Mainstreet 10 - Sebastian Wol - 756189
Mainstreet 7 - Dennis Mann - 694311
...
So "just" delete the lines that contain "Address" but not the first appearance.
I also tried that oneliner:
gawk "!/Address/" filename.txt > newfile.txt
But my output is the same content like my input. So filename.txt == newfile.txt. It's not deleting anything.
Adding my Output doing the following:
I'm converting several csv files to txt using
for /f "tokens=*" %%f in ('dir XLS\*.xls /s /b') do copy "%%f" ".\TXT\%%~nf.txt"
Afterward I'm using a powershellscript to exchange tab delimeter to semicolon using:
for /f "delims=" %%i in ('dir TXT\*.txt /b /s') do powershell.exe -executionpolicy remotesigned -file %powershellscript% -path "%%i" -outPath "Output\%%~nxi"
Now I have several txt files with a semicolon separator in one folder. All of them with the same header. For merging them together without header into one "bigfile" I tried:
(for %%F in (Output\*.txt) do @more +1 "%%F") > output.txt
What is not working. I tried as well:
copy *.txt merged_tempfile.txt
gawk -F";" -v OFS=";" "$1 !~ /Address (CO)/ {print}" merged_tempfile.txt > bigfile.txt
What is not working as well...
When I try to use
gawk dos2unix file1
gawk "!/Address (CO)/" file1.txt > temp1.txt
I only get the same content in temp1 like in file1, with this in last column.
圀嘀圀娀娀娀䄀䄀娀䔀䐀㤀 ㌀㐀㬀攀ⴀ甀瀀℀ 栀椀最栀 㘀 䔀䘀㬀䔀䰀㬀攀ⴀ刀攀洀漀琀攀㬀䈀圀㔀㬀一漀琀爀甀昀洀漀搀甀氀 匀圀ⴀ嘀攀爀猀椀漀渀㬀 ㌀ഀഀ