LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-11-2020, 06:01 AM   #1
mackowiakp
Member
 
Registered: Jun 2014
Location: Poland/Gdynia
Distribution: Mageia 7, SH4, Debian
Posts: 235

Rep: Reputation: 6
Filenames with spaces usin as variable


I have to do the same change in more than 1500 files (video files). In addition, I have a list of these files I have in a single text file. However, the names of these files contain spaces. How can I make these changes to the loop, something like the following shell script. My shell is /bin/sh and not bash. Someone can help me?

Code:
while read p; do
  echo $p #does not display properly video file name
  #My action using $p variable with spaces
done <./files.txt

Last edited by mackowiakp; 07-11-2020 at 06:03 AM. Reason: syntax errors
 
Old 07-11-2020, 06:12 AM   #2
tinfoil3d
Member
 
Registered: Apr 2020
Location: Japan/RJCC
Distribution: debian, lfs, whatever else i need in qemu
Posts: 231

Rep: Reputation: Disabled
its
Code:
echo "$p"
, you must enclose it in double-quotes
 
1 members found this post helpful.
Old 07-11-2020, 06:17 AM   #3
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 18,986

Rep: Reputation: 3281Reputation: 3281Reputation: 3281Reputation: 3281Reputation: 3281Reputation: 3281Reputation: 3281Reputation: 3281Reputation: 3281Reputation: 3281Reputation: 3281
I know you're not using ls, but have a read of this.
 
1 members found this post helpful.
  


Reply

Tags
loop, sh, space, variable


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[Bash] Rename filenames with corresponding filenames Power2All Linux - Software 4 12-02-2009 04:15 AM
filenames with spaces - explain t3___ Linux - Newbie 14 02-17-2004 06:13 PM
BASH scripting problem, spaces in filenames / using basename textures Programming 24 11-16-2003 01:41 AM
Getting rid of "\" before spaces in filenames when using the ls command Locura Linux - Distributions 8 07-05-2003 10:19 PM
spaces in filenames ebone Linux - General 2 11-12-2001 11:56 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:31 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration