Is it possible to cut a string without a line break?
printf 'test.test' prints the test.test without a newline.
But if I cut the output with printf 'test.test' | cut -d. -f1 there's a newline behind test.
Open TextPad and the file you want to edit. Click Search and then Replace. In the Replace window, in the Find what section, type ^\n (caret, backslash 'n') and leave the Replace with section blank, unless you want to replace a blank line with other text. Check the Regular Expression box.
The best way to remove the new line is to add '-n'. This signals not to add a new line. When you want to write more complicated commands or sort everything in a single line, you should use the '-n' option.
Use printf() when you want awk without printing newline.
There are many ways. In addition to isedev and fedorqui's answers, you could also do:
perl -ne '/^([^.]+)/ && print $1' <<< "test.test"cut -d. -f1 <<< "test.test" | tr -d $'\n'cut -d. -f1 <<< "test.test" | perl -pe 's/\n//'while read -d. i; do printf "%s" "$i"; done <<< "test.testIf you don't have to use cut, you can achieve the same result with awk:
printf 'test.test' | awk -F. '{printf($1)}'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With