how to make bash not to wrap output?

Note that this has nothing to do with bash (once you've launched the command, bash just waits for it to finish) and everything to do with the terminal.

Most terminal emulators wrap at the right margin by default. But this can be turned off by using the appropriate control sequence, if the terminal emulator supports it; then long lines are simply truncated:

printf '\033[?7l'
ls -l /a/folder/that/contains/files/with/long/names
printf '\033[?7h'

If you'd like to be able to do horizontal scrolling instead of truncating the lines, use less -S.


You could use a function like so:

nowrap() 
{ 
   cut -c-$(tput cols); 
}

keep in mind though you will have to prefix commands with nowrap or whatever you name the function.