All Questions

Tagged with
Filter by
Sorted by
Tagged with
-4
votes
0answers
40 views

Add newline to ensure stdio is received? [duplicate]

I have this ssh command: ssh -Y ${v.dns} cat /var/lib/backend/version my suspicion is that for files without a new line at the end, the data doesn't get captured properly by ssh etc. maybe ...
0
votes
3answers
171 views

create single string argument using heredoc or other technique

I am trying to execute a script on remote servers, passing the script as the last argument ntrs exec-all-ubuntu --exec `cat << 'EOF' echo "$(pwd)" echo "$foobar" EOF` The problem is that ...
0
votes
1answer
64 views

“nohup cat” — write the complete content to the log file rather to concatenate file

I used the below command nohup cat fastp-filtered/OZBenth*_R1.fastp.fq.gz > fastp-filtered-merged4racon/merge_R1.fq.gz > merge_R1.out.log 2>&1 & but unfortunately, the output went ...
2
votes
4answers
98 views

Combine large amounts of files inside a directory

I have a large amount of files within a single directory, currently 10,804 files. the amount of files can float between 5 and 100,000. I am looking for a way to combine every 250 separate files into ...
0
votes
2answers
57 views

How to use bash cat * to wrap? [duplicate]

ls /proc/ 1 10984 11246 131 144 167 2099 31788 4805 5375 6762 7594 8111 8722 consoles 10 10993 11247 1314 14400 168 21 32 4807 5379 6771 76 8112 ...
-3
votes
1answer
246 views

How does `cat` work so that it allows reading a file line as an array element? [duplicate]

In bash, we can read an file into an array, so that each line in the file becomes an element of the array. $ arr=( $(cat myfile) ) I was wonder how cat works so that it allows reading a file line as ...
1
vote
0answers
45 views

How should I output the contents of a file to terminal without using cat? [duplicate]

I've been hearing talk of UUOC, "Useless Use of cat", lately, and it seems like the consensus is that cat should really only be used when concatenating multiple files. This has me wondering, is there ...
56
votes
1answer
3k views

Change permisions of a file with my cat's help

root@system:~# less myfile -bash: /bin/less: Input/output error The root filesystem is dead. But my cat is still alive (in my memory): root@system:~# cat > /tmp/somefile C^d root@system:~# He's ...
1
vote
2answers
62 views

Fully show all files in a directory — but with some spacing between them

In CentOS with Bash 3.2.52 I desire to fully-show all files in say current dir: cat * All files' outputs are displaying but they are totally juxtaposed one to another... I lack some cosmetic ...
1
vote
1answer
126 views

Copying files based on input list, special characters in file names

This is based on the question here. Problem: I have a .txt file listing file names I want to copy to the folder newfolder in the shell (Mac Terminal). Approach, where filelist.txt contains file ...
0
votes
2answers
67 views

answering command automatically - performing cp operation between answers [closed]

The idea is that I want to execute a command, then it asks for a file name to process, and after it is done with processing, it outputs an image with the name prediction.png, it asks for the next ...
-2
votes
1answer
141 views

What is the difference (if any) between “cat input | tee > output” and “tee < input > output”?

I obtained the following: $ time $(tee < infile > outfile) real 0m14.721s user 0m0.094s sys 0m2.629s $ time $(cat infile | tee > outfile) real 0m8.931s user 0m0.123s sys 0m3.168 Is that ...
0
votes
2answers
299 views

How to I tail the STDOUT of a cat command [duplicate]

Let's say that I start a cat process to wait for some input. e.g., $ cat > out.log In another terminal, I can identify its PID and feed data into its File Descriptor 0 (zero = STDIN), like this: ...
3
votes
2answers
253 views

how to perform a calculation on the output of cat and then format it [closed]

I don't know shell scripting at all, but I have this cat /sys/class/power_supply/BAT0/power_now which gives me the output in milliwatts, which i would like to format as watts and use in watch watch ...
5
votes
4answers
215 views

cat last 5 files in a dir

I have a directory with filenames of the format $date.txt. I would like to cat 5 latest files from it. Is there a more elegant solution to that, than for f in 2*.txt; do echo $f; done | tail -5 | ...
2
votes
1answer
269 views

'ambiguous redirect' error from Bash

I have three directories a,b,c and each have a file named old.txt I would like to copy the contents of the file new.txt to each of these files. My approach is $ cat < new.txt > {a,b,c}/old.txt ...
12
votes
3answers
2k views

Why does “cat {foo}” not output foo, but “cat {foo,bar}” does?

I was trying to concatenate text files in sub-folders and tried: cat ./{mainfolder1,mainfolder2,mainfolder3}/{subfolder1}/book.txt > out$var However this did not return anything. So, tried adding ...
-1
votes
1answer
735 views

bash redirect to file if file does not exist

I have this bash code: if [[ ! -f "$HOME/.oresoftware/package.json" ]]; then cat "node_modules/@oresoftware/package.json" > "$HOME/.oresoftware/package.json"; fi but is there a way ...
0
votes
3answers
56 views

multiple concatenation of strings without writing intermediate files

I would like to extract parts of some files and concatenate them into another but without writing an intermediate file. For instance: $ cat textExample.txt Much I marvelled this ungainly fowl to ...
0
votes
1answer
93 views

Create new concatenated files of same name in multiple directories

I have many files of the same name distributed in many sub-directories with different names (though all at the same level). I'd like to concatenate all the files of the same into a new file with that ...
-1
votes
3answers
491 views

Why cat command doesn't use its command environment? [duplicate]

AFAIK, cat is an external command and it forks off a new process when executed, just like sh -c or executing a script. With that said I expect cat to use its command environment as it is used by ...
1
vote
1answer
41 views

pipeline processing using cat

original: ./A_process.py _ < input.dict > output.dict.tmp ./B_process.py _ < output.dict.tmp > output.dict rm output.dict.tmp I am trying to make it into a pipeline, so cat input.dict | ...
0
votes
0answers
49 views

keep reading files in an updated dir

I have directory, that gets new .gz files during the day. I'd like to have a scripts that I start in the morning, and which keeps reading the data (and possibly processing it) as the new files are ...
4
votes
1answer
258 views

Why does bash replaces text from command substitution with text thereafter

I was trying to parse some nginx config λ tree sites-enabled/ sites-available/ sites-enabled/ ├── bank.cwrcoding.com.conf ├── calendar.cwrcoding.com.conf ├── cloud.cwrcoding.com.conf ├── cwrcoding....
0
votes
2answers
49 views

Source multiple sql files with blank in name

I'm actually blocking on a stupid thing ... yet i can't get it throught. We've got a git repository on which we have our php files and our sql patch. Every time i update my repo, i have to check if ...
0
votes
1answer
63 views

Cannot write text in a file when using here-document [duplicate]

This command doesn't seem to work in my script, how can I decide in which file I want this text, if I just create a file with the following command touch $name I want the text to be in the file $...
0
votes
1answer
49 views

Inconsistent behavior when modifying file in-place with cat, sort, tee, and pipes [duplicate]

Situation: When using the following command: cat foo | sort | tee foo where foo is a text file of multiple lines, the outcome is not consistent. The two outcomes I've observed are: The file is ...
0
votes
2answers
32 views

linux + file printed with the linux prompt

when we print the file- /etc/hosts.txt we get after the last line the - [root@master02 data]# , why? we try dos2linux , and by vi we not see any charterer after the last line - worker03.yu.com 14.23....
-2
votes
3answers
392 views

Bash Cat file to terminal centre

I have a text file with aome ascii art in it. I am trying to get it to print to the terminal on terminal start. I know to do this i add cat myfi in my .bashrc. i am stuck trying to get the output of ...
0
votes
2answers
602 views

bash - add blank line to heredoc via variable

If I am using this scenario in a script: #!/bin/bash addvline=$(if [ "$1" ]; then echo "$1"; echo; fi) cat << EOF this is the first line $addvline this is the last line EOF if $1 is emty I ...
4
votes
4answers
3k views

echo a file as a single line with \n's

I have a multi line text file that I want to echo out as a single line file where the new lines are shown as \n. Any pointers would be great.
0
votes
1answer
1k views

Pipe data from TCP socket connection to terminal

I have this simple line writing JSON to a TCP server echo "{\"some\":\"json-data\"}" > /dev/tcp/localhost/9091 > cat I would have thought that some connection would be created, and the data ...
1
vote
2answers
5k views

Display all files from a directory with cat at the same time

I'm writing a script that would allow me to view the content of every file in an entire selected directory but I don't quite know how to do it. I was thinking about piping the output of ls into cat ...
6
votes
3answers
2k views

How to run local (non-shell) scripts on a remote host via SSH?

How can I make cat someFile | ssh someHost work when someFile is not a bash script? I want to remotely execute a perl script but I get a bunch of syntax errors from bash when I try the cat | ssh ...
0
votes
2answers
138 views

cat file : prints prior to “user :/” prompt

file contains just 1 line: aaa when I run "cat file" it mixes to username user /dir : cat file aaauser /dir : What could be the problem ? Extra Info: perhaps this is not properly set in bashrc ? ...
0
votes
1answer
47 views

How do I append contents from fileA.txt to fileB.txt? [closed]

I am trying to take updated contents from fileA.txt to update fileB.txt's information. I have already tried appending contents from fileA.txt to fileB.txt using the command, "cat /root/important/...
0
votes
1answer
911 views

Piping cat to sendmail not respecting new lines

I have a script which runs a few sanity checks, outputs the results to a file which is then concatenated and piped to a sendmail function as so: { echo "$headers"; echo; cat health_check.log; } | ...
2
votes
2answers
79 views

Will `cat ~/foo* > ~/results/output.txt` preserve the ordering of `~/foo*`?

I have hundreds of files of the form ~/foo.x.y. The files are ~/foo.0001.0010 ~/foo.0011.0020 ~/foo.0021.0030 ... ~/foo.4371.4378 I want to combine all of these files into a big file ~/results/...
1
vote
2answers
673 views

bash script that incorporates content from a file as part of a command

I'm trying to put together what I guess could be called a bash script (not that my bash-scripting abilities are anything to brag about). What I'm trying to do is feed a line from a text file--a text ...
1
vote
2answers
2k views

Specifying comma-separated command line parameters based on text file lines

I want to run a command like: command argument --parameter=param1,param2,param3 where param1, param2, param3 may be any number of parameters coming from a file params.txt, each on one line. I can ...
0
votes
1answer
856 views

Why is `sudo cat /tmp/1 > file` wrong? [duplicate]

I do sudo cat /tmp/1 > /etc/udev/rules.d/69-libmtp.rules but I get bash: /etc/udev/rules.d/69-libmtp.rules: Permission denied System: Ubuntu 16.04 Linux kernel: 4.6
0
votes
2answers
81 views

Add time from all log files using bash

I want to extract time from all of my .log files and add all of these times into a single entity. My log files are placed in nested directories. Directory structure for my log files: |-- temp-system ...
2
votes
1answer
232 views

How to upload a file and then check it and run some other commands using only ssh, cat, and diff in a single SSH session?

The goal is to change some parameters on a lot of devices on connections that are kind of unreliable (wireless)--according to csv that has the format: IP,Parameter,Parameter I would like to make a ...
5
votes
4answers
3k views

Provide default value if command returns with non-zero exit code

I have some configuration in file config and would like to cat that file. However, sometimes config doesn't exist. In this case, I would like to have my command output a default value. Perhaps ...
6
votes
2answers
834 views

Why do here-documents attempt shell substitution even on a commented line?

I wanted to see how some ASCII art looked in terminal so: $ cat <<EOF ...
1
vote
1answer
362 views

Concat all remotely distributed files in your cluster

I want to concatenate all abc_2015-12-15.txt files present on my cluster.Is there any best way to achieve this ? One way is to use below command across all nodes till all files concatenated :- ssh ...
3
votes
5answers
1k views

How do I cat a file I got from stdin without xargs

In an effort to learn the shell better, and without always having to resort to xargs, I have been trying to discover any other ways to do: find . -name *.tcl | xargs -I{} cat {} xargs make it feel ...
4
votes
1answer
275 views

Storing result of cat as different index values

i have parsed a file using catand now I want to save the result of it in array. var1=$(cat abc.txt | grep .........) and the var1 looks like 33 23 51 11 16 43 5 50 4 2 12 29 32 28 47 41 7 20 38 ...
8
votes
6answers
3k views

Force newlines with cat wildcard printing

I want to use cat with wildcards in bash in order to print multiple small files (every file is one sentence) to standard output. However, the separate file contents are not separated by a newline, ...
0
votes
1answer
63 views

How to concatenate tables from different directories with only one header [closed]

I have several directories ("amazon", "niger",...), in which I have several subdirectories ("gfdl", "hadgem",...), in which I also have several sub-directories ("rcp8p5", "rcp4p5",...). In this last ...