Skip to main content

All Questions

Tagged with
0 votes
1 answer
101 views

When storing text on a USB drive, how do I make cat not hang?

Warning: I used these commands on a drive that had nothing on it (/dev/sdb). Do not attempt this on a drive with anything important on it. I was experimenting some, and I discovered that the ...
cocomac's user avatar
  • 545
5 votes
3 answers
2k views

How to align the output generated in a shell "for" loop by columns

I'm trying to align output from a bash for loop. Currently, I'm getting output from my loop that looks like so: Directory: /some/long/directory/path Remote: some-remote Directory: /some/dir/path ...
PGEL's user avatar
  • 187
-1 votes
1 answer
4k views

how to use echo or printf with xargs to iterate over a list from a file?

In poking about with xargs, as here: nicholas@gondor:~/x$ nicholas@gondor:~/x$ xargs echo < list.txt 1 2 3 nicholas@gondor:~/x$ nicholas@gondor:~/x$ cat list.txt 1 2 3 nicholas@gondor:~/x$ how ...
Nicholas Saunders's user avatar
0 votes
2 answers
256 views

delete numbers from a column consisting characters and numbers in bash

I have the following input file H1 C1 C2 C3 H2 C4 . . . I would like to obtain the following output format only with the characters and not the numbers H C C C H C . . .
Dimitris Mintis's user avatar
2 votes
1 answer
68 views

based on a line character, print corresponding number next to it

I have the following input format, H O C H H C H H O C H H C I would like to obtain the following output, H1 O1 C1 H2 H3 C2 H4 H5 O2 C3 H6 H7 C4
Dimitris Mintis's user avatar
0 votes
3 answers
1k views

multiply specific column in a file which consists of thousands columns

The in file looks like this -17.3644 0.00000000 0.00000000 .... -17.2703 0.00000000 0.00000000 .... -17.1761 0.00000000 0.00000000 .... -16.5173 0.00000000 0....
Dimitris Mintis's user avatar
2 votes
3 answers
1k views

How to reverse input order?

The following code provides a backwards output when inputted as first to last, so input is required to be in reverse. How can this be flipped/reversed? EDITED on 2019-05-23_07:52:04 (printf 'g?%s?m0\...
Anonymous's user avatar
  • 533
0 votes
2 answers
628 views

How to modify this `printf` code to reverse it's action?

Code below can, for example ... [anony@mous-pc ~]$ (printf 'g?%s?m0\n' 008 006 004 002 ; printf 'wq\n') | ed -s file.txt ... take all of numbers within ... [anony@mous-pc ~]$ cat some.txt 005 003 ...
Anonymous's user avatar
  • 533
2 votes
1 answer
141 views

Newline character produced by `echo`, is it always there when using no options, regardless of shell?

Although I have read Stephane's answer concentrated on basically all aspects of echo vs printf, I am unsure if it also answers my question, which stands: The newline character produced by echo, is it ...
Vlastimil Burián's user avatar
-2 votes
1 answer
2k views

Printf appending fails

I Tried to run the following similar commands in CentOS (12.x): printf "\nhello" "$HOME"/.bashrc printf "\nhello" ${HOME}/.bashrc After execution I display the content of the .bashrc file and see ...
Arcticooling's user avatar
0 votes
1 answer
30 views

Remove all lines in single file NOT matching keywords aligned in first column [closed]

I need to extract a series of lines identified by a keyword in the first column and print them in the same linear order. The file is divided into sections delimited by a line of hyphens or equal ...
BGarrison's user avatar
3 votes
2 answers
7k views

printf in shell script can't do \x%x

where ECHO-VAR produces \xFF\xFF\xFF\x00 ($fb_COLOR15) these work on the command line: CP="`ECHO-VAR`" printf $CP | dd status=none bs=4 count=$(( ( 1360 * 100 ) + 100 )) > /dev/fb0 printf "`ECHO-...
Paul Wratt's user avatar
1 vote
2 answers
913 views

print multiple words separated by space

I have a text file and the data inside has format like (name age country): michael jordans 25 US adam smith 30 UK chris wood ABC 22 Aus if I use command: cat text.txt | awk {'print $1'} --> it will ...
user175124's user avatar
1 vote
2 answers
238 views

Get the output in a formatted way

In a for loop, I am using the command: echo " Job_time is $i : Stopping the job " Sample output: Job_time is 6 : Stopping the job Job_time is 6.50 : Stopping the job Desired output: Job_time is 6 ...
Afroz's user avatar
  • 11
1 vote
2 answers
2k views

format command output with variable and fixed space

How can I achieve this best maintaining the hierarchy on the left and aligning the size value on the right? Also, at the same time I'd like to round the size to one or two digits. I tried with printf ...
1.61803's user avatar
  • 1,291

15 30 50 per page