Ubuntu не обнаруживает Windows 10 во время установки

Когда я пытаюсь установить Ubuntu 20.04 (или 18.04), он не работает. не дайте мне возможность установить вместе с Windows, вместо этого он просто говорит:

На этом компьютере в настоящее время не обнаружены операционные системы

Моя fastboot также отключена - что кажется решением почти для всех, кто сталкивался с этой проблемой. Вместо ссылки на videodeh.h вот так: $ sudo apt-get install libdc1394-22 libdc1394-22-dev libxine2-dev libv4l-dev v4l-utils $ cd ...

При сборке OpenCV я случайно связал не тот файл заголовка.

Вместо того, чтобы связывать videodeh.h вот так:

$ sudo apt-get install libdc1394-22 libdc1394-22-dev libxine2-dev libv4l-dev v4l-utils
$ cd /usr/include/linux
$ sudo ln -s -f ../libv4l1-videodev.h videodev.h

Я случайно связал videodev2.h , например:

$ sudo apt-get install libdc1394-22 libdc1394-22-dev libxine2-dev libv4l-dev v4l-utils
$ cd /usr/include/linux
$ sudo ln -s -f ../libv4l1-videodev.h videodev2.h

Теперь, когда я отключил videodev2.h ( sudo unlink videodev2.h ), он удалил файл прослушивания из / usr / include / linux .

Я попытался восстановить videodev2.h , установив libv4l-dev и v4l-utils ( sudo apt-get install libv4l-dev v4l-utils ), но безрезультатно. Я также просто скопировал videodev2.h из здесь , но это дает мне эту ошибку при создании opencv:

In file included from /home/rafay/opencv/modules/videoio/src/cap_v4l.cpp:235:
/usr/include/linux/videodev2.h:63:10: fatal error: linux/compiler.h: No such file or directory
 #include <linux/compiler.h>
          ^~~~~~~~~~~~~~~~~~
compilation terminated.

Любая помощь, которая может восстановить videodev2.h без переустановки Ubuntu. У меня есть большой файл с таким содержимым, как показано ниже: --- fruit_file.txt --- фрукты: яблоко апельсин фрукты: виноград плоды манго: банан вишня -> Требуется наличие яблока в каждом из ...

Для ясности

У меня есть большой файл с содержимым, как показано ниже:

--- fruit_file.txt ---

fruit:

apple 
orange

fruit:

grapes
mango

fruit:

banana
cherries

-> Требуется, чтобы в каждом контейнере для фруктов было яблоко, как показано ниже

--- fruit_file.txt ---

fruit:

apple

orange

fruit:

grapes

mango

apple

fruit:

banana

cherries

apple

Пробовали разные способы, есть ли простой способ добиться этого?

2
задан 2 August 2020 в 21:48

4 ответа

Попробуйте использовать sed

sed '/^$/d' fruits.txt | sed '/apple/d' | sed  's/fruit:/\nfruit:\napple/g'> fruits_.txt

sed '/ ^ $ / d' : удалит пустые строки (это необязательно).

sed '/ apple / d ': удалить любую строку, содержащую яблоко .

sed' s / fruit: / \ nfruit: \ napple / g ': добавить яблоко в новая строка после плод:

4
ответ дан 2 August 2020 в 21:58

You probably want to find some commands to achieve that... But I think that it would be easier to do such things with the help of some functional text editors. I recommend to use Visual Studio Code. You can use tool like Find and Replace. You can find every fruit: and replace it with:

fruit:

apple

But if it already has some apple, than in these 'fruit-containers' you can got some duplicates.

0
ответ дан 2 August 2020 в 21:58

Since you have a big file, we shall process each container individually and not load the entire file in memory. We can easily do it in Python3. Save it in process.py and the data in fruits_file.txt

import sys

# This function checks if "apple" not in container then append it.
def add_apple_and_print(container):
    if container is not None:
        if "apple" not in container:
            container.append('apple')

        print("\nfruit:\n")
        print("\n\n".join(container))

# Open the file for reading
with open(sys.argv[1]) as f:

     container = None                     # Initialize the container with None
     for line in f:                       # Read line by line
        line = line.strip()               # Remove trailing spaces
        if len(line) > 0:
            if line == "fruit:":
                add_apple_and_print(container)  # Print privious container
                container = []                  # Create a new container for current fruit section
            else:
                container.append(line)          # Add fruits to container

     add_apple_and_print(container)             # Print last container

then

python3 process.py fruits_file.txt > fruits_file_with_apple.txt
3
ответ дан 2 August 2020 в 21:58

You can process the file in the following way:

0. Let's assume your file looks as this:

cat fruits_file.txt
fruit:

apple
orange

fruit:

grapes
mango

fruit:

banana
cherries

1. Transpose the content of the file into a single line:

paste -s -d ' ' fruits_file.txt
fruit:  apple  orange  fruit:  grapes mango  fruit:  banana cherries

2. Pipe the output of the above command to sed and place new line before the string fruit:, pipe the output |, and use sed gain in order to remove the empty lines:

paste -s -d ' ' fruits_file.txt | sed 's/fruit:/\nfruit:/g' | sed '/^\s*$/d'
fruit:  apple  orange
fruit:  grapes mango
fruit:  banana cherries

3. Pipe the output of the above command to awk in order to append apple at the lines where it is missing:

paste -s -d ' ' fruits_file.txt | sed 's/fruit:/\nfruit:/g' | sed '/^\s*$/d' | \
                      awk '{if (!/apple/) {printf "%s apple\n", $0;} else print}'
fruit:  apple  orange
fruit:  grapes mango
fruit:  banana cherries

4. Pipe the output of the above command to sed in order to replace (expression 1) the multiple spaces by a single space and (expressions 2) append double whitespace at the end of each line:

paste -s -d ' ' fruits_file.txt | sed 's/fruit:/\nfruit:/g' | sed '/^\s*$/d' | \
                      awk '{if (!/apple/) {printf "%s apple\n", $0;} else print}' | \
                      sed -r -e 's/\s{1,9}/ /g' -e 's/\s*$/  /'
fruit: apple orange
fruit: grapes mango apple
fruit: banana cherries apple

5. Pipe the output of the above command to sed again in order to (expression 1) replace each white space by a newline character and (expression 2) add newline before each fruit: string. Then pipe the output to head in order to remove the last two empty lines:

paste -s -d ' ' fruits_file.txt | sed 's/fruit:/\nfruit:/g' | sed '/^\s*$/d' | \
                      awk '{if (!/apple/) {printf "%s apple\n", $0;} else print}' | \
                      sed -r -e 's/\s{1,9}/ /g' -e 's/\s*$/  /'  | \
                      sed -e 's/\s/\n/g' -e 's/fruit:/fruit:\n/' | head -n -2
fruit:

apple
orange


fruit:

grapes
mango
apple


fruit:

banana
cherries
apple

6. Redirect the output of the above command and create a new file:

paste -s -d ' ' fruits_file.txt | sed 's/fruit:/\nfruit:/g' | sed '/^\s*$/d' | \
                      awk '{if (!/apple/) {printf "%s apple\n", $0;} else print}' | \
                      sed -r -e 's/\s{1,9}/ /g' -e 's/\s*$/  /'  | \
                      sed -e 's/\s/\n/g' -e 's/fruit:/fruit:\n/' | head -n -2 \
                      > fruits_new.txt
cat fruits_new.txt
fruit:

apple
orange


fruit:

grapes
mango
apple


fruit:

banana
cherries
apple
4
ответ дан 2 August 2020 в 21:58

Другие вопросы по тегам:

Похожие вопросы: