LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   get file contents with newlines into bash variable (https://www.linuxquestions.org/questions/linux-software-2/get-file-contents-with-newlines-into-bash-variable-274235/)

otoomet 01-05-2005 01:25 PM

get file contents with newlines into bash variable
 
Dear all:

Is it possible to get contents of a text file into the bash variable so that newlines are not deleted?

OR

Is there a better way to get a listing of directory where selected file/subdir names are excluded? Currently I do full listing, exclude selected names by sed, and then use the result.

OR

Are there better ways for excluding files/dirs from 'mkisfs'? '--exclude-list' seems promising, but can I use it together with graft-points? Currently I construct the list of included files and add every single diectory with corresponding graftpoint:
Code:

mkisofs -graft-points file1 dir1=dir1 ...
Otherwise I lose the first-level directories.

Thanks in advance

Ott

zeropash 01-06-2005 09:43 AM

[zeropash@xyz]$ dirlist=`ls -l y`
[zeropash@xyz]$ echo $dirlist
total 0 -rw-rw-r-- 1 rprakash rprakash 0 Jan 6 21:11 file1 -rw-rw-r-- 1 rprakash rprakash 0 Jan 6 21:11 file2 -rw-rw-r-- 1 rprakash rprakash 0 Jan 6 21:11 file3
[zeropash@xyz]$ echo "$dirlist"
total 0
-rw-rw-r-- 1 rprakash rprakash 0 Jan 6 21:11 file1
-rw-rw-r-- 1 rprakash rprakash 0 Jan 6 21:11 file2
-rw-rw-r-- 1 rprakash rprakash 0 Jan 6 21:11 file3

---
OR

[zeropash@xyz]$ cat list_to_exclude
file2
[zeropash@xyz]$ ls y
file1
file2
file3
[zeropash@xyz]$ ls y>list
[zeropash@xyz]$ comm -3 list list_to_exclude
file1
file2

-----
OR
No Idea

otoomet 01-06-2005 01:23 PM

Thanks 8-),

I was not aware of 'comm'.

Best,

Ott


All times are GMT -5. The time now is 12:21 PM.