Hi,
have 2 files (File_A and File_B ) each have a specifc format (fixed with columns, but with a different size)
ex:
File_A
1120120806SUPPORT 111111
2120120806FORUM 423453
File_B
12HELLO 20120806
22THIS IS A TEST20120806
And i whant that my output must be:
20120806SUPPORT 111111
HELLO 20120806
20120806FORUM 423453
THIS IS A TEST20120806
I need to join this two files, sort by the first 2 characters ans remove it.
To join the files i'm doing
cat File_A File_B > File_C
and to order it
sort File_C > File_D
How can i remove the first two columns ?
cut columns from file
Moderator: DosItHelp
Re: cut columns from file
Try this: file1.txt and file2.txt are input files, it writes to file3.txt
Code: Select all
@echo off
setlocal DisableDelayedExpansion
< file2.txt (
for /F "delims=" %%a in (file1.txt) do (
set file2Line=
set /P file2Line=
set "file1Line=%%a"
setlocal EnableDelayedExpansion
>>file3.txt echo(!file1Line:~2!
>>file3.txt echo(!file2Line:~2!
endlocal
)
)
Re: cut columns from file
I misread your post, try this:
Edit: fixed syntax error
Edit: fixed syntax error
Code: Select all
@echo off
setlocal EnableDelayedExpansion
copy /a file1.txt + file2.txt file3.txt
sort file3.txt >file4.txt
for /F "delims=" %%a in (file4.txt) do (
set "Line=%%a"
>>file5.txt echo(!Line:~2!
)