что я могу использовать вместо чтения пути к файлу, я пробовал, чтение имени файла не помогло, путь к файлу не сработал, я попробовал все, но не могу это исправить, пожалуйста
Function to Edit an existing file
edit_existing_file() {
echo "Enter the full path or name of the file to edit:"
read filepath
if [ -f "$filepath" ]; then
# Display file contents with line numbers
nl "$filepath"
cat > "$filepath.tmp" # Create temporary file to store new text
mv "$filepath.tmp" "$filepath" # Replace original file with the one containing new text
echo "File edited."
else
echo "File not found."
fi
}
# Function to Edit an existing file
edit_existing_file() {
echo "Enter the name of the file or the full file path to edit:"
read filename
if [ -f "$filename" ]; then
# Display file contents with line numbers
nl "$filename"
echo "Enter the new content below. Press Ctrl+D when finished:"
cat > "$filename.tmp" # Create temporary file to store new text
mv "$filename.tmp" "$filename" # Replace original file with the one containing new text
echo "File edited."
else
echo "File not found."
fi
}
Подробнее здесь: https://stackoverflow.com/questions/784 ... d-filepath
Что я могу использовать вместо чтения пути к файлу [закрыто] ⇐ Linux
-
Anonymous
1714801657
Anonymous
что я могу использовать вместо чтения пути к файлу, я пробовал, чтение имени файла не помогло, путь к файлу не сработал, я попробовал все, но не могу это исправить, пожалуйста
Function to Edit an existing file
edit_existing_file() {
echo "Enter the full path or name of the file to edit:"
read filepath
if [ -f "$filepath" ]; then
# Display file contents with line numbers
nl "$filepath"
cat > "$filepath.tmp" # Create temporary file to store new text
mv "$filepath.tmp" "$filepath" # Replace original file with the one containing new text
echo "File edited."
else
echo "File not found."
fi
}
# Function to Edit an existing file
edit_existing_file() {
echo "Enter the name of the file or the full file path to edit:"
read filename
if [ -f "$filename" ]; then
# Display file contents with line numbers
nl "$filename"
echo "Enter the new content below. Press Ctrl+D when finished:"
cat > "$filename.tmp" # Create temporary file to store new text
mv "$filename.tmp" "$filename" # Replace original file with the one containing new text
echo "File edited."
else
echo "File not found."
fi
}
Подробнее здесь: [url]https://stackoverflow.com/questions/78427324/what-can-i-use-instead-read-filepath[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия