I have a large number of files that contain backslashes \
that I would like to manipulate, but whenever I try something like:
$ ls -li
2036553851 -rw-rw-r-- 1 user user 6757 May 20 00:10 Simplex_config\\B1:B3\\_1.csv
2036553766 -rw-rw-r-- 1 user user 6756 May 20 00:07 Simplex_config\\B1:B3\\_2.csv
2036554099 -rw-rw-r-- 1 user user 6785 May 20 00:20 Simplex_config\\B1:B3\\_3.csv
2036553974 -rw-rw-r-- 1 user user 6785 May 20 00:15 Simplex_config\\B1:B3\\_4.csv
$ find . -type f -name 'Simplex*.csv' | xargs cat > looksee.txt
I receive a No such file or directory
error. I have considered changing the filenames and then manipulating, but I am curious to see if there was an easier solution with the inode
.
I came up with:
#!/bin/sh
if [ -f looksee.txt ]; then
rm -rf looksee.txt
fi
ls -i Simplex_config*.csv | awk '{ print $1 }' > inode_list.txt
while IFS= read -r inode;
do
find . -inum $inode -exec cat {} \; >> looksee.txt
done < inode_list.txt
But this is very cumbersome and I would like to try to find a way to parse the output from ls -i Simplex_config*.csv
and pipe it to another command in a one-liner -- is there such an option available?
find . -type f -name 'Simplex*.csv' -print0 | xargs -0 cat > looksee.txt
or evenfind . -type f -name 'Simplex*.csv' -exec cat {} + > looksee.txt
– Costas May 20 '15 at 13:26-print0
/-0
in the first and the+
in the second make this possible? – mlegge May 20 '15 at 13:30ls Simplex_config*.csv
have enough recursion for you why do you do not usecat Simplex_config*.csv > looksee.txt
– Costas May 20 '15 at 13:31