I'm trying to figure out how to use cat more wisely. I have the following command, which works, but I'd like to understand how to get it to work more clearly and efficiently.
Unfortunately, the quotes are preventing the wildcard from working. So my first question is, is there a way to get the wildcard thing to work when you need to use quotes?
The second thing is after running the command, nothing happens. I get no feedback as to what's happening. So the second question is, is there a way to make cat more verbose?
You can use double-quotes to tell the shell not to split arguments on whitespaces, but still substitute globs and variables, eg:
As for verbosity, cat isn't really that telling. You could put another command at the end to tell you that it's done, or you'll have to use some coding:
If it's a one-shot thing, just copy & paste it into a terminal. If you need it more than once, put it into a file, write a shebang
into the very first line, save. Note that it will always look for 'my file.*' files in the current directory.
---------- Post updated at 03:09 PM ---------- Previous update was at 01:20 PM ----------
Well, I checked out the mini script, and it isn't actually working.
Here's what I found. First, it doesn't look like double-quotes matter. You still get file not found errors. Only by placing the * outside the quotes, or double-quotes in this case, are the files recognized.
As well, it seems that instead of appending one file to the next, somehow, at least the way I tried it, the output file was being rm before the next append, so each file was simply appending to a now non-existing file.
As I understand it, wherever you say "my file" that means the filename of the output file, correct? So then the only place we're referring to the input files are the line:
You're right, the asterisk should be outside the quotes. Sorry, should have caught that, correct version below. But I can' reproduce your other error (disappearing output file).
Yes, when I say 'my file' I mean the output file, and 'my file.*' refers to the input files, as per your original post. and the for-loop is the only line that references the input files by name. Inside the loop, the name of the current file in the variable 'file'.
I will like to merge several files using 'cat', but I observe the output is not consistent. the merge begins at the last line of the first file.
file1.txt:
1234
1234
1234
file2.txt:
aaaa
bbbb
cccc
dddd
cat file1.txt file2.txt > file3.txt
file3.txt:
1234
1234
1234aaaa
bbbb
cccc... (13 Replies)
Hi,
Is there any way to do a cat * where it shows the name of each file in the process? Similar to what more does below?
$ more ?.sql
::::::::::::::
1.sql
::::::::::::::
set linesize 200
select db_unique_name,
cast(
from_tz(
cast(... (5 Replies)
I have a text file in this format
Some lines....
Question no: 1
The question?
A. Answer 1
B. Answer 2
C. Answer 3
D. Answer 4
Answer:B
Some lines....
Question no: 2
The question? (choose 2) (10 Replies)
I have a folder that contains a number of files with file names as follows:
XX.YYYY..ZZZ.2014.001.000000
XX.YYYY..ZZZ.2014.001.000400
XX.YYYY..ZZZ.2014.001.000800
XX.YYYY..ZZZ.2014.001.001200
XX.YYYY..ZZZ.2014.001.001600
.....
XX.YYYY..ZZZ.2014.002.000000
XX.YYYY..ZZZ.2014.002.000400... (8 Replies)
I have a number of files in a directory named like this:
fooP1, fooN1, fooP2, fooN2 ... fooP(i), fooN(i).
I'd like to know how to combine each P and N pair into a single file, foo(i)
TIA
John Balwit (1 Reply)
Hopefully the title summarized what I need help with. I have multiple files that I would like to concatenate in bash.
ie:
cat file1 file2 file3 > bigfile
except I do not want to include the first line from each file (). Any help? Thanks. (6 Replies)
Hi all,
I have a directory with many subdirectories each named like so: KOG0001, KOG0002, ...KOG9999.
Each of these subdirectories contain a variable number two kinds of files (nuc and prot) named like so: Capitella_sp_nuc_hits.fasta (nuc) and Capitella_sp_prot_hits.fasta (prot). The... (2 Replies)
Hi,
I was a typical Windows guy. Like to do things just by clicking my mouse:cool:. I got a new job now...where they are big on unix.
I am trying to wet my fingures now with unix. Haven't taken the dive yet.
I am trying to find a solution for this problem.
Please help me with some... (4 Replies)
Can you have a second primary slice on a second hdd?
I know that primary slices are defined in the mbr, but where are all the sub partitions defined at?
From the OBSD installation FAQ:
What exactly is in the PBR? (0 Replies)