0
votes
2answers
68 views

cat wc -l count lines line with defined line endings (e.g Mac OS X specific)

As any command-line user I sometimes want to count lines in text file with well known command: cat some_text_file | wc -l I face the problem on Mac OS X, which as far I have it studied is connected ...
9
votes
1answer
195 views

Security concerns of displaying ssh private key

I've made I huge mistake, or at least I think it is: I've "catted" my private SSH key cat ~/.ssh/id_rsa I'm now afraid that I've created a security hole, allowing other users to see my private key ...
1
vote
1answer
83 views

head and cat don't recognize Microsoft Excel text files

I have a large .xls file with 53760 rows and 19 columns. I saved it as Tab Delimited Text in order to pre-process it through command line tools and load it into R later. However, when I run head ...
-1
votes
2answers
84 views

Execute a command for 3 lines at a time

I'm trying to run three separate processed while reading foo.txt Here is the example: cat foo.txt | while read line do echo line1 echo line2 echo line3 echo "" done The expected output is: line1 ...
2
votes
1answer
105 views

Can cat be used to clone a partition?

For example, can I do: cat /dev/sda1 > /dev/sda2 instead of using dd, and if not, why will this not work?
0
votes
0answers
56 views

Special and diacritic charactres using less, cat and other linux tools

I am using GNU bash, Version 4.1.10(4)-release (i686-pc-cygwin) and set up my .inputrc to allow for special characters and German umlauts etc.: set meta-flag on set convert-meta off set output-meta ...
1
vote
2answers
148 views

Why did my bash prompt turn to gibberish after I accidentally ran `cat` on a .coverage file?

I had just installed coverage and run it a few times when I noticed a .coverage file hanging around in my repo, which is -- according to the file utility -- a 8086 relocatable (Microsoft) file. And ...
1
vote
4answers
949 views

Cannot cat file which has space in name in linux

I believe there's a simple fix but cannot debug it out. I have file called "file name with space" How do I cat this file from Linux bash ?
1
vote
6answers
6k views

how to copy entire linux root filesystem to new hard drive on with ssh and tar

I know I've found this information before, but can't remember the right google query. I need to transfer an entire linux root filesystem off of a failing hard drive onto another computer with an ...
0
votes
1answer
144 views

Write output to $TMPDIR/$variable : file does not exist (should be created)

I have the following .sh script in which I am trying to do all major writing in $TMPDIR. However, when it gets to line 86, it returns the following error: ...
1
vote
1answer
91 views

How to prepend contents of a file to another

This question relates to the already asked question How to add text to beginning of file The answer suggested by Dennis Williamson does the job: echo 'task goes here' | cat - todo.txt > temp ...
0
votes
1answer
85 views

cat command outputs the whole directory when used in a bash script

I have a scirpt like this: #!/bash/bin file=`cat /proc/net/arp` echo $file And when I run the script it outputs the whole folder where the script is like this: IP address HW type Flags HW address ...
0
votes
1answer
270 views

Combining multiple data files with header while also adding a data column

I have multiple tab delimited data files that are separated by month in the format jan06.txt, feb06.txt, ..., dec07.txt. Within each file, it looks something like: Header1 Header2 Header3 ... Data1 ...
3
votes
5answers
4k views

How to display the file contents recursively?

I always have to submit the source codes in my printed assignment report. I have to copy and paste my course codes into the document and I find that it is an annoying task. I want to solve this "copy ...
1
vote
1answer
46 views

Creating a new file that has one line added to to the first line and one line added to the last

I need help or I will do this is python instead (by reading one line at a time) which I know I should not need to. I have large number of text files that I get using find. FILES=$(find ... -iname ...
8
votes
1answer
3k views

Why is cat not changing the access time?

The second call to cat a file does not update the access time. I was expecting the access time to be updated ever time a file contents gets displayed. I see the same behaviour if I open the file in ...
3
votes
3answers
2k views

Can I use pipe output as a shell script argument?

Suppose I have a bash shell script called Myscript.sh that need on argument as input. But I want the content of the text file called text.txt to be that argument. I have tried this but it does not ...
0
votes
2answers
243 views

Join parts of two files together in Bash

I hope to draw on the knowledge of those who know far more about scripting than I. I have two files, F1 and F2, where F2 is located in a sub-directory of F1. I need to output a new file, F3, that ...
1
vote
1answer
151 views

Pass an option syntax string as filename

I somehow got a file named --no-recursion in a directory. How can I get cat to show what it contains? Not like this, since the argument gets interpreted as an option: root@nagini [/home/lalilulelo]# ...
0
votes
3answers
410 views

Scripts shell recording playback

I hope this makes sense. I use 'scripts' to make copies of my ssh sessions for various reasons. When I access the logs via less, etc, I see this: Script started on Mon 12 Sep 2011 08:59:14 AM CDT ...
2
votes
3answers
1k views

How to recursively find a .doc file that contains a specific word?

I'm using bash under Ubuntu. Currently this works well for the current directory: catdoc *.doc | grep "specificword" But I have lots of subdirectories with .doc files. How can I search for, ...
1
vote
4answers
612 views

Overwrite a file with an edited version in bash

What's the shortest code that does this? I've been doing something like echo "header" > tmpfile cat $file >> tmpfile echo "footer" >> tmpfile mv tmpfile $file . Is there a more ...
5
votes
3answers
705 views

Is it wasteful to call cat?

I'm sorry if this question is really stupid, but this is basically what I have been thinking about constantly: Suppose I run : cat ./somefile.txt a few hundred times a second. How much faster is my ...
3
votes
2answers
978 views

Linux cat example

Can You please explain me why: 'cat < file.txt > file.txt ' makes file.txt empty ?