Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
I have a very big file and I want to remove the space character in the file.
The 'sed' can be used but it is very slow.
Is there any command that can use fixed string instead of regexto replace or remove space.
You can use tr command (see manpage for more information):
cat filename | tr -d "\t\n\r"
It has option to define character class also. Eg:
To delete all whitespace:
cat filename | tr -d "[:space:]"
To delete all horizontal whitespace:
cat filename | tr -d "[:blank:]"
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 months ago.
Improve this question
I have a string in shell script:
string1="0101122100635014,TEST123 22 SEP 06 PQR BC,14,25,0.05,,0915-1530|1815-1915:17,2022-09-30,1665066600,ABC:TEST123629500AB,10,11,90014,TEST123,26009,29500.0,BC"
I want to extract ABC:TEST123629500AB in shell scripting.
echo $string1 | magical command
output: ABC:TEST123629500AB
echo "$string1" | cut -d',' -f10
cut will give you part of string.
-d define the separator.
-f Specifies the column you want based on the separator
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I am using
sed -s n v
Nothing works for me
The -i flag is only in GNU Sed.
cat file | tr ']' '[' > temp
mv temp file
The above should work for you.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I have an output from a program that I would like to process and If I pipe it to a file I get:
file/path#backup2018
file2/path/more/path/path#backup2019
file3/path#backup2017
And I want to process it so it looks like this:
file/path file.path
file2/path/more/path/path file.path.more.path.path
file3/path file.path
I have figured out how to make it with separate commands but would like a one liner.
$ awk -F# '{s=$1; gsub("/", ".", s); print $1, s}' file | column -t
file/path file.path
file2/path/more/path/path file2.path.more.path.path
file3/path file3.path
using sed
sed 's/\([^#]*\)#.*/\1 \1/g' file|column -t
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I want to find a pattern starting from a specific line rather than from the beginning and then delete all the lines starting from this specific position to the point/line where the pattern was first matched.
This will delete starting from line 10 until the pattern is matched:
sed '10,/pattern/d' file > newfile
what about this:
sed -e "$lineno,/$pattern/d" $file
where
$lineno is your line number for start deleting
$pattern is your pattern
$file is your file
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I'm trying to prepend and append a header and trailer to a very large file.
So far I have tried sed and awk. Sed I can't get to work at all on the Mac with examples online. Awk I have go to work but only displaying to screen output.
Using this site as reference.
http://www.theunixschool.com/2011/03/different-ways-to-add-header-and.html
Using AWk how do I actually get this to update my file. Open to other suggestions too.
cat header big_file footer > tmp_file && mv tmp_file big_file
This works on unix/linux:
cat headerfile myfile trailerfile > newfile