Problem setting path to external hard drive as a variable


 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers Problem setting path to external hard drive as a variable
Prev   Next
# 2  
Old 02-16-2019
Hi
Code:
prev_dir= /Volumes/My\ Passport/test_reads_folder_a

remove the space after the equal sign
Code:
prev_dir=/Volumes/My\ Passport/test_reads_folder_a

Enclose the variable in double quotes.
Code:
cd "$prev_dir"

--- Post updated at 05:49 ---

instead of this command. so do not override variables
Code:
sed -i '' 's/\r$//' $i
echo $i

use this expression.
Code:
echo ${i%?}

--- Post updated at 06:20 ---

It's all unnecessary
Code:
#!/bin/sh
prev_dir=/Volumes/My\ Passport/test_reads_folder_a
new_dir=/Users/mylapple/desktop/test_reads_folder_b
file=targeted_files.txt
sed 's/\r$//' "$prev_dir"/$file >"$new_dir"/$file

--- Post updated at 06:31 ---

If this experiment then is better so
Code:
while read -r d; do
    sed 's/\r$//' <<<"$d"
done <"$prev_dir"/$file >"$new_dir"/$file

--- Post updated at 06:40 ---

I tried to delete a character \r so
echo ${var%\r} and so echo ${var%[\r]} Did not work out.
This expression is not correct since any last character will be deleted. echo ${var%?}
The only way echo ${var%[[:cntrl:]]}
This User Gave Thanks to nezabudka For This Post:
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

External hard drive

I have connected an external hard drive. I can't find it. Both ls /media, fdisk -l and ls /dev show nothing. TIA (3 Replies)
Discussion started by: Meow613
3 Replies

2. Shell Programming and Scripting

I want to copy all files of a said type on my external hard drive

My code is this, what I'm trying to accomplish is to make a list of all pdf documents in my computer and then copy all of those documents to my external hard drive in a directory mkdir /Volumes/Hardrive-1/allpdf echo "File Locations" > /Volumes/Hardrive-1/allpdf/FileLocations.txt mdfind pdf... (2 Replies)
Discussion started by: darpness
2 Replies

3. Ubuntu

How to install Ubuntu11 in external Hard drive

Hi Guys.. I want to install Linux on my portable hard drive. I created a 20GB partition in my hard drive for linux, Now I want to make it bootable mean when I connect it to system n start the system it will start the LINUX and when start without usb-hard drive it should start the windows. ... (3 Replies)
Discussion started by: atul9806
3 Replies

4. Solaris

Boot Solaris off of an old external hard drive

Hi Folks, First a little background, I am working on a ship that operates in the Indian Ocean and Persian/Arabian gulf area. We had a Sunblade 2000 that finally died. The Video board burned up and I guess damaged the mother board. So we ordered 2 rebuilt 2000s one as a spare. Due to mounting... (1 Reply)
Discussion started by: Sean.kelly
1 Replies

5. Solaris

Connect an External SCSI Hard Drive to Ultra 80

Guys, I have googled and checked this forum in detail and couldn't find any satisfactory answers for my problem. I am trying to connect a external SCSI hard Drive(Sea Gate) to a Ultra 80. I connected it powered it up and at OK prompt did : boot -r system comes up and complains about not... (6 Replies)
Discussion started by: ajnabi
6 Replies

6. HP-UX

Mounting an external parallel hard drive

Can anyone please walk me through how to mount an external parallel (or scsi) hard drive in visualize C3000 machine? I also would like to mount "/var/sallie" directory in that external drive. My "/var/sallie" directory is running out of space so I would like to mount an external hard drive so that... (0 Replies)
Discussion started by: sallysallie
0 Replies

7. Ubuntu

External Hard drive won't mount

i have a Simple Tech hard drive that i use between two computers. it is formatted to ntfs. i have a dell desktop with Ubuntu 7.10 and Ubuntu 8.04 and Windows XP Home. and i have a laptop with Ubuntu 7.10 and Ubuntu 8.04. the laptop recognizes the hard drive on both 8.04 and 7.10 but my desktop... (9 Replies)
Discussion started by: Texasone
9 Replies

8. UNIX for Dummies Questions & Answers

External SCSI hard drive

Someone gave me a small external SCSI hard drive for my SunOS 5.8 test system. How do I make Unix see the hard drive? (2 Replies)
Discussion started by: FredSmith
2 Replies

9. Solaris

FAT32 usb external hard drive - how to mount??

Hello ! What is the comand to mount and usb hard disk ? I have Solaris 10 installed! 10nx! (1 Reply)
Discussion started by: daniel.balasa
1 Replies

10. UNIX for Dummies Questions & Answers

listing directories of an external hard drive

How do I do it? I have a mac and a pc and am having a time cd-ing to the external drive. (2 Replies)
Discussion started by: theGooch
2 Replies
Login or Register to Ask a Question