Три часа очередной непрерывной борьбы за правильный формат файла...
Люди, умеющие писать скрипты, помрут от ужаса и смеха одновременно. Чувствую себя вырезающей весь вечер на коленке деревянную ложку в век расплавленного металла, пластмассы и 3D принтеров. Завтра наберусь смелости и пойду за советом- " а как это делают нормальные люди?" А сегодня спать и, таки, не без некой гордости. Все таки победила.
Что-бы не забыть:
# Formatting the file. A column with end coordinates needed.
# copying 3rd column to the fifth.
$ cat file | awk '{ $5=$3; print;}'
# swapping 4th and 5th columns
$ cat file | awk '{ temp=$5; $5=$4; $4=temp; print; }' > outputfile
# substract constant (1) from the 4th column
$ awk '{print $1 " " $2 " " $3 " " ($4 - 1) " " $5}' inputfile > outputfile
# to cut the 4th column and paste into the new file
$ cut -d' ' -f4 inputfile > outputfile
# to delete the first character in inputfile 4th column manually
# to merge two files- file1 and file2 (side by side)
$ paste -d " " file1 file2 > merged
# to write 1,2,3,5 and 6th column in the new file
$ cut -d' ' -f1,2,3,5,6 merged > outputfile
# to swap the columns 4 and 5
$ cat inputfile | awk '{ temp=$5; $5=$4; $4=temp; print; }' > outputfile
# and go to sleep!!!!
No comments:
Post a Comment