Skip to main content

All Questions

0 votes
3 answers
102 views

Splitting Words into space separated characters [duplicate]

I have a table with one word in each row. I want to split the word into space separated c h a r a c t e r s. Is there a way to do that via bash command? If yes, I also have a table with multiple words ...
Daniel Capkan SamuriLPT's user avatar
-2 votes
1 answer
182 views

Error in command su

I am creating a command that will change a certain line in the /etc/profile file from a script, however in certain versions of Linux the sudo command may not be activated so it would be necessary to ...
user avatar
0 votes
2 answers
269 views

Get value from a key value pair separated with pipe

I have a string as below Delete :xna.del|mode:Full|Execution: loaded I need my output to be stored in 3 parameters. for an example a=xna.del b=Full c=loaded
user3416176's user avatar
3 votes
7 answers
2k views

remove trailing spaces from text files ONLY when necessary

I'm removing the trailing spaces using sed -i 's/[ \t]*$//' *.txt However, this command will rewrite all the files. Is there a convenient way to judge that if there are trailing spaces in a text file ...
wsdzbm's user avatar
  • 2,926
1 vote
1 answer
344 views

process input arguments to a bash script

I'm processing files with a bash script $ processh.sh file. The input file contains information about the files to process # id path type id1 filename1 csv id2 filename2 id3 filename3 json ... ...
wsdzbm's user avatar
  • 2,926
3 votes
2 answers
7k views

How to loop through file and execute the lines

I have a text file that contains bash commands for fetching some data from a database. Each command is separated with a newline. See an example below: (the commands could also have been "ls -l&...
GoldenRetriever's user avatar
6 votes
4 answers
3k views

How to print multi-line variables in side-by-side columns in sh?

This question is based on a similar question on Ask Ubuntu, but instead of bash, I would like to have similar output in sh. No issue in bash; it works as expected. wolf@linux:~$ echo $SHELL /usr/bin/...
Wolf's user avatar
  • 1,731
0 votes
2 answers
130 views

How to change columns, drop inverted commas and add tabulation to a text file with bash

I'm quite new into bash and awk in bash scripting and from this text that I have in a file: "Index", "Year", "Age", "Name", "Movie" 1, 1928, 44, "...
4F0X4's user avatar
  • 101
-3 votes
1 answer
805 views

remove duplicate lines based on first three column values

I am getting a file with content below The first three values might be repeating in other lines I want to keep one instance and remove other duplicates the output should be like below
sravani's user avatar
  • 11
0 votes
1 answer
41 views

How can I place a column after another column for 1000 files?

I have 1000 odt files: file 1.odt with 6 columns (x,y,z,mx1,my1,mz1) file 2.odt with another 6 columns (x,y,z,mx2,my2,mz2) .... file 1000.odt with 5 columns (x,y,z,mx1000,my1000,mz1000) How can put ...
Eduardo Saavedra's user avatar
-3 votes
4 answers
8k views

Write a unix command to count total number of word in first n lines of file?

How can I count the words in the first 3 lines? input: There are many systems which are Unix-like in their architecture. Not able among these are the GNU/Linux distributions. The distinctions ...
ruchi rout's user avatar
0 votes
0 answers
51 views

Is there a way to pipe to a visual editor and then continue the pipeline? [duplicate]

I know that some command-line programs can open visual editors like Sublime in a "wait mode" which opens the editor, lets you edit, and on-close it resumes the program with the file contents (like git ...
ak0000's user avatar
  • 215
8 votes
3 answers
1k views

Looking for a way to view lines of a text file one-at-a-time centered on screen

I'm looking for a way to take a text file and put each line one-at-a-time centered on screen with a certain character width. Sort of like a bare-bones slide show, e.g. seeing the first line until the ...
ak0000's user avatar
  • 215
0 votes
1 answer
2k views

How to bash a Copy files from large text file with source and destination values in it?

I'm trying to write a script that will copy all file listed in a text file, around 3 million lines, which contains two columns, the source and the destination with a new filename: path/to/source/...
msarcom's user avatar
1 vote
3 answers
5k views

How to separate a file into parts by delimiter

I have a text file as follows: aaaa bbbb ---- cccc ---- dddd How can I use ---- as delimiter and take out for example dddd or cccc? By take out I mean run a command and get "dddd" if my input ...
Turgon's user avatar
  • 165

15 30 50 per page